Microsoft has a solution to "Allow WEBAPI CORS requests"
Http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api
If you use Owin at the same time, even if you use this, you cannot make Owin allow Cross-origin requests.
OWIN is a set of OAUTH2.0 solutions based on Kantana.
So to use DLL Microsoft.OWIN.Cros
I installedMicrosoft.Owin.Cors
The package is on the API Server. InchStartup.Auth.cs
File, underpublic void ConfigureAuth(IAppBuilder app)
, I added in
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
InchWebApiConfig.cs
, underpublic static void Register(HttpConfiguration config)
, I added in these lines:
// Corsvar cors = new EnableCorsAttribute("*", "*", "GET, POST, OPTIONS");config.EnableCors(cors);
Or the most direct method ()!!!!
<customHeaders>
<add name= "Access-control-allow-origin" value= "*"/>
<add name= "Access-control-allow-methods" value= "GET, POST, OPTIONS, PUT, DELETE"/>
</customHeaders>
Add this section to the <system.webServer> node of Web. config, success!