enabling cross-origin resource sharing on IIS7

后端 未结 10 2204
轻奢々
轻奢々 2020-11-22 15:22

I recently ran into with posting Javascript requests to another domain. By default XHR posting to other domains is not allowed.

Following the instructions from htt

10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 15:34

    The 405 response is a "Method not allowed" response. It sounds like your server isn't properly configured to handle CORS preflight requests. You need to do two things:

    1) Enable IIS7 to respond to HTTP OPTIONS requests. You are getting the 405 because IIS7 is rejecting the OPTIONS request. I don't know how to do this as I'm not familiar with IIS7, but there are probably others on Stack Overflow who do.

    2) Configure your application to respond to CORS preflight requests. You can do this by adding the following two lines underneath the Access-Control-Allow-Origin line in the section:

    
    
    

    You may have to add other values to the Access-Control-Allow-Headers section based on what headers your request is asking for. Do you have the sample code for making a request?

    You can learn more about CORS and CORS preflight here: http://www.html5rocks.com/en/tutorials/cors/

提交回复
热议问题