What is CORS in ASP.NET Core? Why is CORS restriction required? How to fix CORS error?

v CORS stands for Cross-Origin Resource Sharing.

v CORS is a security feature implemented in web browsers that restricts web pages or scripts from making requests to a different domain than the one that served the web page. 

CORS stands for Cross-Origin Resource Sharing.
 
CORS is a security feature implemented in web browsers that restricts web pages or scripts from making requests to a different domain than the one that served the web page. 
 
Why CORS is required?

Because of security reason. So that you can make your api secure by default. Otherwise, any external website can try to access your data.

How to fix CORS error?
 
Add Microsoft.AspNetCore.Cors nuget package to your project.
In startup class, edit the Configure and ConfigureServices method.
 

Post a Comment

Previous Post Next Post