Rip Page Inspector out of your Web Site Projects now

less than 1 minute read,

Page Inspector causing multiple calls to HttpApplication : Application_Start in Web Site Projects

image

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 processed. Specifically, Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.
    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=1.0.0.0, 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,
Brian Chavez

Updated:

Comments

Dmitry

Many thanks! Disabling PageInspector in web.config helped me to solve high CPU usage problem (by unknown non-my threads) under MVC5, VS2013 and Win 8.1.

Plank György

Than you!
I could not imagine why my website throw errors in VS generated codefiles when tried to build in VS2012.4 or VS2013.

JeroenW

Thanks a lot! Page load went from 13,5 seconds to 1,2 seconds. Found the culprit through DotTrace (Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.BrowserLinkExecutionListener.GetOutputPositionTracker() taking up 49 percent of the call).

Lakhwinder Arora

The performance issue introduced in MVC App after token implementation is gone after disabling PageInspector:ServerCodeMappingSupport

Thanks

Leave a comment

Your email address will not be published. Required fields are marked *

Loading...