admin管理员组

文章数量:1406942

Response to preflight request doesn't pass access control check.

XMLHttpRequest cannot load http://localhost:49531/Access/Authenticate. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:31775' is therefore not allowed access.

I am flushing request ing with OPTIONS. Request returns with code 200, however I am still getting this error.

protected void Application_BeginRequest()
        {
            if (Request.Headers.AllKeys.Contains("Origin") && Request.HttpMethod == "OPTIONS")
            {
                Response.Flush();
                Response.End();
            }
        }

What I am trying to do is to adding a token to header from client side and server side. Once client has been authenticated, token is added to request from server. From next request initiated from client, this token is sent by javascript.

本文标签: javascriptCORS Response to preflight request doesn39t pass access control checkStack Overflow