IIS hijacks CORS Preflight OPTIONS request

后端 未结 12 1119
说谎
说谎 2020-11-27 03:57

I am making a CORS POST request and setting the Content-Type header to json. This triggers a Preflight OPTIONS request to fire (this is good and expected)

This OPTIO

12条回答
  •  执笔经年
    2020-11-27 04:51

    I had the same issue and the following web.config settings fixed it for me.

        
          
        
        
          
          
          
        
    

    I was then able to handle CORS OPTIONS requests manually in Application_BeginRequest.

    I was originally using the library detailed in this blog post for handling CORS requests. The product I'm working on requires that runAllManagedModulesForAllRequests be set to false, though. This is why I had to set up a custom implementation, but if you don't have that requirement you should give that library a try. It worked great when I was able to have runAllManagedModulesForAllRequests set to true.

提交回复
热议问题