Base solution for your next web application
Open Closed

Enabling CORS on a web service #808

naeazach created

So I installed package: Microsoft.AspNet.WebApi.Cors to the web project and followed instructions found here:

<a class="postlink" href=""> ... 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: "", headers: "*", methods: "*")]
    public async Task&lt;List&lt;Project.Sub.Marketing.Webinar&gt;> 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
    ismcagdas created
    Support Team


    You can check this topic #[email protected].

    As a short answer, after adding nuget package you need to enable cors in WebModule class like


    Also you need to use EnableCors attribute in app service interface for dynamic api methods not in app service itself.