I am buildind a Web Api app locally and I am calling the methods using simple jQuery ajax method calls. As per the title I have installed the Microsoft.AspNet.Cors package via nuget and enabled cors in my WebApiConfig.cs and on my controller like this
[EnableCors(origins: "https://localhost:44397", headers: "", methods: "", exposedHeaders: "X-My-Header")]
I have even tried this
[EnableCors(origins: "", headers: "", methods: "", exposedHeaders: "")]
but when I make the call via ajax I still get the error - Access to XMLHttpRequest at 'https://localhost:44397/api/Default/PostRegisterUser' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Why is this happening and how do I resolve this?