enabling cross-origin resource sharing on IIS7

后端 未结 10 2140
轻奢々
轻奢々 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:33

    With ASP.net Web API 2 install Microsoft ASP.NET Cross Origin support via nuget.

    http://enable-cors.org/server_aspnet.html

    public static void Register(HttpConfiguration config)
    {
     var enableCorsAttribute = new EnableCorsAttribute("http://mydomain.com",
                                                       "Origin, Content-Type, Accept",
                                                       "GET, PUT, POST, DELETE, OPTIONS");
            config.EnableCors(enableCorsAttribute);
    }
    

提交回复
热议问题