December 2019
Intermediate to advanced
510 pages
11h 33m
English
In some cases, it may be necessary to define specific policies for some routes or actions. Therefore, it is possible to apply CORS policies using attributes, as follows:
namespace Catalog.API.Controllers{ [Route("api/items")] [ApiController] [JsonException] [EnableCors("BlogDomainPolicy")] public class ItemController : ControllerBase { ... }}
In this case, we are restricting the use of the BlogDomainPolicy only to the ItemController. Therefore, all of the routes defined under the controller will use the same policy. In the same way, we can add the policy to a specific action method in the controller:
namespace Catalog.API.Controllers{ [Route("api/items")] [ApiController] [JsonException] [ ...
Read now
Unlock full access