concept CORS in category asp.net

appears as: CORS
ASP.NET Core in Action

This is an excerpt from Manning's book ASP.NET Core in Action.

18.4.1. Understanding CORS and how it works

CORS is a web standard that allows your Web API to make statements about who can make cross-origin requests to it. For example, you could make statements such as

  • Add the CORS middleware to enable CORS for your entire app or decorate your MVC action with the [EnableCors] attribute to selectively enable CORS
  • Figure 18.14. With CORS enabled, cross-origin requests can be made and the browser will make the response available to the JavaScript. Compare this to figure 18.12, in which the request was blocked.

    Applying CORS globally to your application in this way may be overkill. If there’s only a subset of actions in your API that need to be accessed from other origins, then it’s prudent to only enable CORS for those specific actions. This can be achieved with the [EnableCors] attribute.