AreaRegistration.RegisterAllAreas() 在使用 Application Insights 时永远不会完成

AreaRegistration.RegisterAllAreas() never finishes when using Application Insights

我使用 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,重新启动我的电脑,无论我做什么,这个方法都会永远挂起。看起来不只是慢,因为我已经等了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>

能否提供更多详细信息,以便我们重现此问题?

  • 您使用什么操作系统(Windows 版本)?
  • 您运行是在 IIS Express 还是常规 IIS 上创建 Web 应用程序?

  • 如果这是常规 IIS,您使用什么应用程序池模式 (integrated/classic)?

  • 您选择哪个 .NET Framework 版本来创建应用程序?
  • 您的应用程序基于哪个 MVC 版本?
  • 您是否为您的网络应用程序项目启用了 WebAPI 或 WebForms?