Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AreaRegistration.RegisterAllAreas() never finishes when using Application Insights

I created a new ASP.net MVC application using Visual Studio 2013 Update 4 and checked the box to use Application Insights. When I try and run the application (with or without debugging) the site never loads. When I debug it I noticed that it is getting stuck in Global.asax.cs on the line:

AreaRegistration.RegisterAllAreas();

I have taken a look at the answers on a few other questions including this one: AreaRegistration.RegisterAllAreas() is not Registering Rules For Area

This did not solve my issue. I have deleted all of the content in the folders in this answer and restarted visual studio, restarted my PC and no matter what I do this method just hangs forever. It doesn't appear to just be slow, because I have waited for over 5 minutes and it still hasn't finished. Has anyone else run into this scenario and how can I fix it other than removing this call?

It appears if I comment out the Http Module registration for Application Insights then this method finishes right away, but as soon as I add them back the method hangs again. There appears to be some problem with the AreaRegistration.RegisterAllAreas() call and Application Insights.

<httpModules>
    <!-- removing this makes everything work -->
    <!-- <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Extensibility.Web.RequestTracking.WebRequestTrackingModule, Microsoft.ApplicationInsights.Extensibility.Web" /> -->
</httpModules>

<modules>
  <remove name="FormsAuthentication" />
  <!-- removing these makes things work -->
  <!-- 
  <remove name="ApplicationInsightsWebTracking" />
  <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Extensibility.Web.RequestTracking.WebRequestTrackingModule, Microsoft.ApplicationInsights.Extensibility.Web" preCondition="managedHandler" />
  -->
</modules>
like image 273
Dismissile Avatar asked Nov 01 '22 11:11

Dismissile


1 Answers

Yes i have the same situation and what i have done is remove appinsight element and apply xml transformation between debug and release web.config file. This helps me when me want to debug and include appinsight when release.

<system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)" />
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Extensibility.Web.RequestTracking.WebRequestTrackingModule, Microsoft.ApplicationInsights.Extensibility.Web"
           xdt:Transform="Insert"/>
    </httpModules>

  </system.web>

  <system.webServer>
    <modules>
      <remove name="ApplicationInsightsWebTracking" xdt:Transform="Insert"/>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Extensibility.Web.RequestTracking.WebRequestTrackingModule, Microsoft.ApplicationInsights.Extensibility.Web" preCondition="managedHandler" xdt:Transform="Insert" />
    </modules>
</system.webServer>
like image 124
duongthaiha Avatar answered Nov 11 '22 13:11

duongthaiha