So I installed package: Microsoft.AspNet.WebApi.Cors to the web project and followed instructions found here:
<a class="postlink" href="http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api">http://www.asp.net/web-api/overview/sec ... in-web-api</a>
However, I am still being blocked. I think because of automated api config through aspnetzero framework that the cors set up is being superceded by something else. Any idea how to get this working? Thanks. This is what my service method looks like:
[EnableCors(origins: "http://site.com", headers: "*", methods: "*")]
public async Task<List<Project.Sub.Marketing.Webinar>> GetWebinars()
{
var webinars = await _webinarRepository.GetAllListAsync();
return webinars.Where(a => a.InSession == false && a.WebinarAccount == "x" && a.StartTime >= today).OrderBy(a => a.StartTime).ToList();
}
1 Answer(s)
-
0
Hi,
You can check this topic #448@6bab272b-0a26-41ea-b1f4-6c3381bffea0.
As a short answer, after adding nuget package you need to enable cors in WebModule class like
GlobalConfiguration.Configuration.EnableCors();
Also you need to use EnableCors attribute in app service interface for dynamic api methods not in app service itself.