首页 文章

Application Insights仅跟踪失败的ASP.NET MVC Web API请求

提问于
浏览
3

我有一个ASP.NET Web API控制器,提供saveAndNew操作 .

此类根据预期派生自System.Web.Http.ApiController .

使用SDK的2.1.0版和ApplicationInsights.config中的默认设置正确配置了Application Insights .

如果请求 the mentioned operation fails - 例如,在App Insights中使用状态代码400 - the request is recorded correctly .

问题是 if the operation SUCCEEDS (状态代码200) nothing is recorded in Application Insights .

我已经使用Fiddler查看是否向App Insights跟踪服务发出了请求,但事实并非如此 . 因此问题不在于Azure门户上的Application Insights配置 .

我无法弄清楚是什么阻止了对我的Web API控制器操作的所有请求被记录 .

有人可以帮忙吗?

1 回答

  • 5

    您可能想尝试删除/注释掉ApplicationInsights.config文件中的TransferRequestHandler .

    GitHub问题"REST API app can have all requests filtered out" here指出:“注释掉ApplicationInsights.config中的一行导致成功请求开始记录.Web API 2项目 .

    <!--<Add>System.Web.Handlers.TransferRequestHandler</Add>-->
    

相关问题