Page Inspector causing multiple calls to HttpApplication : Application_Start in Web Site Projects
I had a mysterious problem receiving multiple calls to Application_Start on almost every HTTP request to IISExpress. Upon further investigation, I found Visual Studio 2012’s Page Inspector causing the problem.
Inside the default machine’s Web.config located at: Windows\Microsoft.NET\Framework\v4.0.30319\Config, XPath: \System.Web\compilation\assemblies has an assembly “Microsoft.VisualStudio.Web.PageInspector.Loader”, which dynamically loads itself via [assembly: PreApplicationStartmethod(typeof(RuntimeLoader),”PreApplicationStart”] attribute.
The ASP.NET BuildManager’s hash of the compiled web site project
kept changing upon the first & subsequent request to IISExpress. Somehow
the dynamically loaded PageInsepctor.Runtime caused the
HttpApplication to shutdown, startup, in an oscillating fashion
(hence, the mulitiple Application_Start calls) as requests were being
SelectionMappingExecutionListenerModule.PreApplicationStart()’s call to BuildManager.AddCompilationDependency() caused root compilation hash to change.
Disabling and removing Microsoft’s Page Inspector feature removed the restarting interference. Here’s how to remove the entire feature from your project:
Disable Visual Studio 2012 Page Inspector
To disable visual studio Page Inspector remove the assembly inside your Web.config located in configuration/compilation/assemblies:
<compilation debug="true" targetFramework="4.5"> <assemblies> <remove assembly="Microsoft.VisualStudio.Web.PageInspector.Loader, Version=18.104.22.168, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> </assemblies> </compilation>
Alternatively, you can add this to your appSettings:
<appSettings> <add key="PageInspector:ServerCodeMappingSupport" value="Disabled" /> </appSettings>
Hope that helps,
Share onTwitter Facebook Google+ LinkedIn
Leave a comment
Your email address will not be published. Required fields are marked *