OPTIONS 405 (Method Not Allowed) regardless server sends Access-Control-Allow-Methods:OPTIONS, GET, HEAD, POST

后端 未结 3 826
太阳男子
太阳男子 2021-02-06 01:34

I\'m trying to make cross-domain request and my server is configured to send the following headers:

Access-Control-Allow-Credentials:true
Access-Control-Allow-He         


        
3条回答
  •  深忆病人
    2021-02-06 01:58

    I would suggest 2 solutions:

    1) If you are using WebAPI you need to implement the option method that by convention should look like:

    public class XXXController : ApiController
    {
        // OPTION http-verb handler
        public string OptionsXXX()
        {
            return null; // HTTP 200 response with empty body
        }
    
        ...
    }
    

    2) If you are not using WebAPI try to understand which part of your code triggers the OPTIONS 405 (Method Not Allowed) error for the OPTION call. In that case I would check if trying to add to the Web.config file these that works:

    
      
        
          
            
            
            
            
          
        
      
    
    

提交回复
热议问题