-1

I'm using AI on an Angular site with a WebAPI backend.

I'm setting the AuthenticatedUserContext and I can see the info being attached as cookies when doing http requests to my API. Because of CORS there is a pre-flight http OPTIONS request and as expected this request does not include the AI cookies.

Looking at the telemetry data in AI I can only see the OPTIONS requests but not the GET/POST request. The session and Authenticated user info is not attached to the OPTIONS request. Why is the OPTIONS request recorded but not the GET/POST? How can I record the GET/POST requests without the OPTIONS requests

</p>

4

1 回答 1

2

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

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

过滤使用这个文档。你会有这样的代码:

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;
        }
    }
}
于 2017-03-15T20:21:17.807 回答