我使用Visual Studio 2013 Update 4创建了一个新的ASP.net MVC应用程序,并选中了使用Application Insights的框。当我尝试运行该应用程序(有或没有调试)时,该站点永远不会加载。当我调试它时,我注意到它被卡在Global.asax.cs中:

AreaRegistration.RegisterAllAreas();

我看了一下其他一些问题的答案,包括这个问题:
AreaRegistration.RegisterAllAreas() is not Registering Rules For Area

这没有解决我的问题。我已删除此答案中文件夹中的所有内容,并重新启动了Visual Studio,重新启动了我的PC,无论我做什么,此方法都会永久挂起。它似乎并不慢,因为我已经等待了5分钟以上,但还没有完成。还有其他人遇到这种情况吗?除了删除此调用之外,我该如何解决?

如果我注释掉Application Insights的Http模块注册,则会出现该方法,该方法立即完成,但是一旦我将它们重新添加回去,该方法就会再次挂起。 AreaRegistration.RegisterAllAreas()调用和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>

最佳答案

是的,我有相同的情况,我要做的是删除appinsight元素,并在调试和发布web.config文件之间应用xml转换。当我要调试并在发布时包含appinsight时,这对我有帮助。

<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>

关于c# - 使用Application Insights时AreaRegistration.RegisterAllAreas()永远不会完成,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27906032/

10-10 02:25