ImageResizer - ParseQueryOnly - Response is not available in this context, when initialized on production server - imageresizer

This error occurs only in our production enviromnent, not locally or on the test server. I´ve narrowed it down to the preset-node in the configuration. The exception is thrown when I have presets defined and start the web site. If I comment the preset-element the site starts and images can be scaled manually through the query params.
The call stack:
Exception Details: System.Web.HttpException: Response is not available in this context.
[HttpException (0x80004005): Response is not available in this context.]
System.Web.HttpUtility.UrlDecode(String str, Encoding e) +4841588
ImageResizer.Util.PathUtils.ParseQueryOnly(String query, Boolean allowSemicolons, Boolean urlDecode) +307
ImageResizer.ResizeSettings..ctor(String queryString) +224
ImageResizer.Plugins.Basic.Presets.ParseXml(Node n, Config conf) +870
ImageResizer.Plugins.Basic.Presets.Install(Config c) +98
ImageResizer.Configuration.PluginConfig.loadPluginsInternal() +303
ImageResizer.Configuration.PluginConfig.LoadPlugins() +61
ImageResizer.Configuration.Config.get_Current() +109
[HttpException (0x80004005): Response is not available in this context.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +3985477
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +191
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +325
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +407
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +375
[HttpException (0x80004005): Response is not available in this context.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11524352
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4782309

This regression in the ASP.NET framework was introduced in .NET 4.0 RTM, and has been patched in a later updates to the framework.
It made HttpUtility.UrlEncode dependent upon having a valid HttpContext.
More details about the bug can be found here.

Related

Sensenet Move Server

I'm simply trying to move a site created by a third party to a new server. I'm getting an assembly error but I checked the project is set to move references local. I'm not familiar with sensenet so thought maybe someone could help.
ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) +0
System.Reflection.RuntimeModule.GetTypes() +9
System.Reflection.Assembly.GetTypes() +61
SenseNet.ContentRepository.Storage.TypeHandler.GetTypesByBaseType(Type baseType) in \Source\SenseNet\Storage\TypeHandler.cs:211
[ApplicationException: Type discovery error. Assembly: BotDetect.Web.Mvc, Version=4.4.2.0, Culture=neutral, PublicKeyToken=74616036388b765f]
SenseNet.ContentRepository.Storage.TypeHandler.GetTypesByBaseType(Type baseType) in \Source\SenseNet\Storage\TypeHandler.cs:230
SenseNet.ContentRepository.Storage.Schema.NodeTypeManager.GatherNodeObservers() in \Source\SenseNet\Storage\Schema\NodeTypeManager.cs:123
SenseNet.ContentRepository.Storage.Schema.NodeTypeManager.StartEventSystem() in \Source\SenseNet\Storage\Schema\NodeTypeManager.cs:130
SenseNet.ContentRepository.Storage.Schema.NodeTypeManager.get_Current() in Source\SenseNet\Storage\Schema\NodeTypeManager.cs:50
SenseNet.ContentRepository.RepositoryInstance.StartManagers() in Source\SenseNet\ContentRepository\RepositoryInstance.cs:230
SenseNet.ContentRepository.RepositoryInstance.DoStart() in Source\SenseNet\ContentRepository\RepositoryInstance.cs:125
SenseNet.ContentRepository.RepositoryInstance.Start(RepositoryStartSettings settings) in \Source\SenseNet\ContentRepository\RepositoryInstance.cs:98
SenseNet.ContentRepository.Repository.Start(RepositoryStartSettings settings) in \Source\SenseNet\ContentRepository\Repository.cs:58
SenseNet.Portal.SenseNetGlobal.Application_Start(Object sender, EventArgs e, HttpApplication application) in \Source\SenseNet\Portal\SenseNetGlobal.cs:67
SenseNet.Portal.Global.Application_Start(Object sender, EventArgs e) in D:\Xavor\NVIP(Latest)\Source\SenseNet\Portal\Global.cs:9
[HttpException (0x80004005): Type discovery error. Assembly: BotDetect.Web.Mvc, Version=4.4.2.0, Culture=neutral, PublicKeyToken=74616036388b765f]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +10096597
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +173
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +218
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Type discovery error. Assembly: BotDetect.Web.Mvc, Version=4.4.2.0, Culture=neutral, PublicKeyToken=74616036388b765f]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10077812
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

On start of asp.net mvc 4 application getting ambiguous exception- Index and length must refer to a location within the string. Parameter name: length

Here's the stack trace.
[ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length]
System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +10699039
System.Web.HttpApplication.HookupEventHandlersForApplicationAndModules(MethodInfo[] handlers) +312
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +107
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Index and length must refer to a location within the string.
Parameter name: length]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9874568
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Is there any way to find out where this exception is coming from other than throwing random breakpoints everywhere? Thanks!
I ran into the same issue and was able to resolve it.
It turns out that at some point I fat-fingered something while in Global.asax.cs. I ended up changing the method Application_Error to Application_ (with a new line after it, stupid wide fingers...). This is what was causing the error to appear for me. Rewriting it as Application_Error resolved the issue.

Exception from NinjectMvcHttpApplicationPlugin via Ninject.MVC3 Bootstrapper (in MVC4)

I know there are some questions already on this topic but I am still missing something that is causing this error. I installed ninject.mvc3 package which installs ninject and ninject.web.common packages. No modification was made in global.asax (as suggested in official documentation).
App_Start/NinjectWebCommon.cs's RegisterServices method has the Bind statement after loading the Kernel. I am getting this error with this stack trace when I try to run the site.
[InvalidOperationException: Sequence contains no elements]
System.Linq.Enumerable.Single(IEnumerable`1 source) +379
Ninject.Web.Mvc.NinjectMvcHttpApplicationPlugin.Start() in c:\Projects\Ninject\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\NinjectMvcHttpApplicationPlugin.cs:53
Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map(IEnumerable`1 series, Action`1 action) in c:\Projects\Ninject\ninject\src\Ninject\Infrastructure\Language\ExtensionsForIEnumerableOfT.cs:32
Ninject.Web.Common.Bootstrapper.Initialize(Func`1 createKernelCallback) in c:\Projects\Ninject\Ninject.Web.Common\src\Ninject.Web.Common\Bootstrapper.cs:53
Ninject.Web.Common.NinjectHttpApplication.Application_Start() in c:\Projects\Ninject\Ninject.Web.Common\src\Ninject.Web.Common\NinjectHttpApplication.cs:81
[HttpException (0x80004005): Sequence contains no elements]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12864673
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475
[HttpException (0x80004005): Sequence contains no elements]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881540
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722601
What step am I still missing?
The source says on line 53:
ModelValidatorProviders.Providers.Remove(
ModelValidatorProviders.Providers.OfType<DataAnnotationsModelValidatorProvider>)
.Single());
Have you in some way inhibited the addition of the DataAnnotationsModelValidatorProvider ? Probably not - therefore I suggest you've got two copies of the same logic in your system - do you have >1 NinjectWebCommon.cs ?
Another thing worth trying (in general - I have no specif reason why it should fix this case for you) is see if the same thing still happens when you use the Include Prerelease NuGet packages.

Castle Windsor Dynamic Assembly Bug?

I'm using Castle Windsor 3.1.0 in an ASP .NET 4 MVC application, which is giving me an exception in the Application_Start event when container.Register is called.
The exception is "The invoked member is not supported in a dynamic assembly.". Here's the stack trace:
[NotSupportedException: The invoked member is not supported in a dynamic assembly.]
System.Reflection.Emit.InternalAssemblyBuilder.GetExportedTypes() +56
Castle.Core.Internal.ReflectionUtil.GetAvailableTypes(Assembly assembly, Boolean includeNonExported) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\Core\Internal\ReflectionUtil.cs:165
Castle.MicroKernel.Registration.FromAssemblyDescriptor.<SelectedTypes>b__0(Assembly a) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\MicroKernel\Registration\FromAssemblyDescriptor.cs:56
System.Linq.<SelectManyIterator>d__14`2.MoveNext() +238
Castle.MicroKernel.Registration.FromDescriptor.Castle.MicroKernel.Registration.IRegistration.Register(IKernelInternal kernel) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\MicroKernel\Registration\FromDescriptor.cs:160
Castle.MicroKernel.Registration.BasedOnDescriptor.Castle.MicroKernel.Registration.IRegistration.Register(IKernelInternal kernel) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\MicroKernel\Registration\BasedOnDescriptor.cs:530
Castle.MicroKernel.DefaultKernel.Register(IRegistration[] registrations) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\MicroKernel\DefaultKernel.cs:506
Castle.Windsor.WindsorContainer.Register(IRegistration[] registrations) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\Windsor\WindsorContainer.cs:483
ProductX.Web.Windsor.Installers.ControllerInstaller.Install(IWindsorContainer container, IConfigurationStore store) in C:\TeamProjects\CompanyX.ProductX\Mainline\Admin\ProductX.Web\Windsor\Installers\ControllerInstaller.cs:24
Castle.Windsor.Installer.AssemblyInstaller.Install(IWindsorContainer container, IConfigurationStore store) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\Windsor\Installer\AssemblyInstaller.cs:56
Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers, DefaultComponentInstaller scope) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\Windsor\WindsorContainer.cs:319
Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\Windsor\WindsorContainer.cs:452
ProductX.Web.MvcApplication.InitializeWindsor() in C:\TeamProjects\CompanyX.ProductX\Mainline\Admin\ProductX.Web\Global.asax.cs:41
ProductX.Web.MvcApplication.Application_Start() in C:\TeamProjects\CompanyX.ProductX\Mainline\Admin\ProductX.Web\Global.asax.cs:25
[HttpException (0x80004005): The invoked member is not supported in a dynamic assembly.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9171773
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +131
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +194
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +253
[HttpException (0x80004005): The invoked member is not supported in a dynamic assembly.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9090876
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256
Here's how I'm calling Register:
container.Register(Classes.FromThisAssembly().BasedOn<IController>().LifestyleTransient());
When I build the application in Debug mode, it's fine. When I build in Release mode, the exception above occurrs. I can't find anything about this error through Google. My suspicion is that some .NET 4 restrictions were introduced with how reflection is done on dynamic assemblies, which is being introduced in this situation as a Release build optimisation.
Any idea anyone?
Looks like you're getting a dynamic assembly being emitted (somehow). Try adding a filter to ignore dynamic assemblies. This should work:
container.Register(Classes.FromThisAssembly().Where(t => !t.Assembly.IsDynamic).BasedOn<IController>().LifestyleTransient());

Reporting server: Server Error in '/Reports' Application

I am trying to setup SQL Reporting services on windows vista, iis7 but I keep getting this error when I try http://localhost/Reports/Pages/Folder.aspx
Server Error in '/Reports' Application.
Request is not available in this context Description: An unhandled
exception occurred during the execution of the current web request.
Please review the stack trace for more information about the error and
where it originated in the code. Exception Details:
System.Web.HttpException: Request is not available in this context
Source Error: An unhandled exception was generated during the
execution of the current web request. Information regarding the origin
and location of the exception can be identified using the exception
stack trace below. Stack Trace: [HttpException (0x80004005):
Request is not available in this context]
System.Web.HttpContext.get_Request()
+3465893 Microsoft.ReportingServices.UI.Global.get_ConfigurationManager()
+47 Microsoft.ReportingServices.UI.GlobalApp.Application_Start(Object
sender, EventArgs e) +32 [HttpException (0x80004005): Request is not
available in this context]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext
context, HttpApplication app)
+3385130 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
appContext, HttpContext context, MethodInfo[] handlers) +125
System.Web.HttpApplication.InitSpecial(HttpApplicationState state,
MethodInfo[] handlers, IntPtr appContext, HttpContext context)
+182 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext, HttpContext context)
+259 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext) +245 [HttpException (0x80004005): Request is not available
in this context]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +3465475
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +69
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +675
The event viewer shows me something like this:
3005 An unhandled exception has occurred. 10/30/2008 12:31:56
PM 10/30/2008 9:31:56 AM d6764b0e70d246a590d9a9e8186ef677
2 1 0 /LM/W3SVC/1/ROOT/Reports-8-128698327158150000
RosettaMgr /Reports c:\Program Files\Microsoft SQL
Server\MSSQL.4\Reporting Services\ReportManager\
4756 w3wp.exe NT AUTHORITY\NETWORK SERVICE HttpException Request is not available in this context
http://localhost/Reports/Pages/Folder.aspx
/Reports/Pages/Folder.aspx ::1
False
NT AUTHORITY\NETWORK SERVICE 5 NT AUTHORITY\NETWORK SERVICE False at
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext
context, HttpApplication app) at
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
appContext, HttpContext context, MethodInfo[] handlers) at
System.Web.HttpApplication.InitSpecial(HttpApplicationState state,
MethodInfo[] handlers, IntPtr appContext, HttpContext context) at
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext, HttpContext context) at
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext)
Take a look at http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3459824&SiteID=1 - looks like someone had the same issue and was able to resolve it.