CORS issues occurs randomly

Asked by At

I am developing Web Api which passes data to mobile Application.My issue is Mobile Application facing CORS issue but randomly.Its working fyn sometimes.

I have already enabled cors by simply writing

[EnableCors(origins: "", headers: "", methods: "*")] in all controllers as public

and config.EnableCors();

in WebApiConfig.cs file

[EnableCors(origins: "", headers: "", methods: "*")]

The issue occurs sometime And I need permanant solution . And May I know if the issue is on client side or serverside.

Help me on this.Thanks in advance.

1 Answers

Manikandan Murugesan On
 var cors = new EnableCorsAttribute("*", "*", "*", "*") { SupportsCredentials = true };

Add this to the WebApiConfig.cs file, you can remove the Cors attribute from the controllers. This should work.