Response for preflight has invalid HTTP status code 405

后端 未结 6 846
轻奢々
轻奢々 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 11:59

    Solution that worked for me:

    1. Add this to web.config (server-side):

       
        
          
          
          
        
      
      
    2. Create a Global.asax file (Global application class) and add the following code:

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

提交回复
热议问题