Skip to content Skip to sidebar Skip to footer

Response For Preflight Has Invalid Http Status Code 400 - Aspx

I am writing both server and client using visual studio 2015. The following problem occurs in Chrome and FireFox, but works perfect in Explorer. I am doing a Rest post call using A

Solution 1:

The solution was to add the following to the Global.asax file

protected void Application_BeginRequest()
{
    var context = HttpContext.Current;
    var response = context.Response;


    if (context.Request.HttpMethod == "OPTIONS")
    {
        response.AddHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
        response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept");
        response.End();
    }
}

Post a Comment for "Response For Preflight Has Invalid Http Status Code 400 - Aspx"