Response for preflight has invalid HTTP status code 405

后端 未结 6 834
轻奢々
轻奢々 2020-12-06 11:06

I have read many similar problems in StackOverflow, but the solutions doesn\'t work for me.

I have WCF REST service:

[]            


        
6条回答
  •  粉色の甜心
    2020-12-06 12:07

    I want to show what work for me.

    First you must enable CORS on web.config (like Mihai sad):

    
      
        
        
        
      
    
    

    If you have some extra HEADER parameter, you must add it to Access-Control-Allow-Headers, like:

    
    

    And finally, to handle OPTIONS requests you must reply with empty response, adding in your application class:

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

提交回复
热议问题