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

标签 c# asp.net-mvc azure-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,重新启动了我的 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# - AreaRegistration.RegisterAllAreas() 在使用 Application Insights 时永远不会完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27906032/

相关文章:

c# - 如何用空格字符替换无数字字符?

asp.net - 如何为 Web API GET 请求指定用户名和密码

asp.net-mvc - Visual Studio 在运行时打开当前解决方案之外的不同解决方案

azure - App Insights GetMetric ("name").TrackValue 在 App Insights 门户中查看时不会聚合

c# - 如何安全地将包含转义 JSON 的字符串转换为有效的 JSON?

c# - 将Json Property的Property反序列化为Property

c# - 用户登录后更新声明

azure-application-insights - Application Insights - 无法查看 SQL 查询

c# - .NET Core 2.1 - 在 NPE 中设置 Azure Insights 采样配置结果

c# - C#中的多重继承