How do I add CORS headers to my MVC6 application? I am interested in Globally and per action.
It seems like ASP.Net vNext/5/Core has undergone some changes so there are different answers to this question for different versions. I'm using RC1.
I have tried this SO "How to enable CORS in ASP.NET Core", but coming to var policy = new Microsoft.AspNet.Cors.Core.CorsPolicy();
the "Core" namespace does not exist.
Tried the answer in "How do you enable cross-origin requests (CORS) in ASP.NET 5 & MVC 6?" but the method/extension methodservices.ConfigureCors
does not exist.
The last SO answer is the same as this blog post, which also says to first install Microsoft.AspNet.Cors (Install-Package Microsoft.AspNet.Cors
). But doing so makes things worse, then services.AddCors()
doesn't exist for some reason.
"Enable cross-origin requests (CORS) in ASP.NET 5 & MVC 6" says to install "Microsoft.AspNet.Cors.Core" which does not exist, and using Microsoft.AspNet.Builder;
which doesn't help.