Rip Page Inspector out of your Web Site Projects now

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:

Code Snippet
  1. <compilation debug="true" targetFramework="4.5">
  2.   <assemblies>
  3.     <remove assembly="Microsoft.VisualStudio.Web.PageInspector.Loader,
                          Version=1.0.0.0, Culture=neutral,
                          PublicKeyToken=b03f5f7f11d50a3a"
    />
  4.   </assemblies>
  5. </compilation>

Alternatively, you can add this to your appSettings:

Code Snippet
  1. <appSettings>
  2.   <add key="PageInspector:ServerCodeMappingSupport" value="Disabled" />
  3. </appSettings>

Hope that helps,
Brian Chavez

Comments

# re: Rip Page Inspector out of your Web Site Projects now
Gravatar I am pretty happy to read your blog post.
Left by Allen dave on 12/10/2013 11:35 PM
# re: Rip Page Inspector out of your Web Site Projects now
Gravatar 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.
Left by Dmitry on 5/14/2014 11:27 PM
# re: Rip Page Inspector out of your Web Site Projects now
Gravatar Than you!
I could not imagine why my website throw errors in VS generated codefiles when tried to build in VS2012.4 or VS2013.
Left by Plank György on 9/11/2014 5:12 AM
# re: Rip Page Inspector out of your Web Site Projects now
Gravatar I've also seen this thing throw stack overflows when loading certain types of .ASPX pages.
Left by Zach on 9/23/2014 10:35 AM
# re: Rip Page Inspector out of your Web Site Projects now
Gravatar 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).
Left by JeroenW on 12/28/2014 11:58 PM
# re: Rip Page Inspector out of your Web Site Projects now
Gravatar The performance issue introduced in MVC App after token implementation is gone after disabling PageInspector:ServerCodeMappingSupport

Thanks
Left by Lakhwinder Arora on 10/5/2016 9:54 AM

Leave Your Comment

Title*
Name*
Email (never displayed)
 (will show your gravatar)
Url
Comment*

Please add 6 and 6 and type the answer here:

Preview Your Comment.