I have an MVC6 site running in Visual Studio 2015 RC
I've got some static HTML files I want to serve to another website. I want to add CORS support (without having to add a controller and add CORS that way).
Does anyone know how to do this please?
I have an MVC6 site running in Visual Studio 2015 RC
I've got some static HTML files I want to serve to another website. I want to add CORS support (without having to add a controller and add CORS that way).
Does anyone know how to do this please?
You need to allow the server to accept CORS.
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
Client(browser) must know that server accepts the CORS because browser checks for the Allow Cors in the response of server, if it's allowed or not and then it allows displaying data even if it's static content like plain HTML.
In Startup.cs
Configure the policy in ConfigureServices ...
Then in Configure set the app to use the policy, then set UseStaticFiles ...
Ensure that UseStaticFiles() comes after UseCors - at least in the version I'm using (installed with Visual Studio 2015 RC) it needs to come after UseCors()