应用程序见解:记录了 HTTP 选项,但忽略了 GET/POST

问题描述 投票:0回答:1

我在带有 WebAPI 后端的 Angular 网站上使用 AI。

我正在设置 AuthenticatedUserContext,当向我的 API 发出 http 请求时,我可以看到信息被附加为 cookie。由于 CORS,存在飞行前 http OPTIONS 请求,并且正如预期的那样,该请求不包含 AI cookie。

查看 AI 中的遥测数据,我只能看到 OPTIONS 请求,但看不到 GET/POST 请求。会话和经过身份验证的用户信息未附加到 OPTIONS 请求。为什么记录了 OPTIONS 请求而没有记录 GET/POST?如何在没有 OPTIONS 请求的情况下记录 GET/POST 请求

ufeff

angularjs cookies cors azure-application-insights http-options-method
1个回答
4
投票

我在msdn论坛回复你了。也在这里回复一下:

我认为你遇到了bug。 GitHub 问题有一个解决方法建议,您可以尝试

要进行过滤,请使用此doc。你将得到这样的代码:

using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;

public class SuccessfulDependencyFilter : ITelemetryProcessor
{
    private ITelemetryProcessor Next { get; set; }

    // Link processors to each other in a chain.
    public SuccessfulDependencyFilter(ITelemetryProcessor next)
    {
        this.Next = next;
    }

    public void Process(ITelemetry item)
    {
        if (!OKtoSend(item)) { return; }

        this.Next.Process(item);
    }

    private bool OKtoSend (ITelemetry item)
    {
        var request = item as RequestTelemetry;

        //if its not a Request, return true.  We don't care to filter it here
        if (request == null) return true;

        if (request.Name.StartsWith("OPTIONS")) //CORS Pre Flight Request
        {
            return false;
        }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.