December 2019
Intermediate to advanced
510 pages
11h 33m
English
The CORS middleware approach can be used to enable a specific HTTP domain, method, or port to call our service. As with any middleware, it can be defined in the Startup class of the service, specifically in the Configure method:
namespace Catalog.API{ public class Startup { ... public void Configure(IApplicationBuilder app, IWebHostingEnvironment env) { ... app.UseCors(cfg => { cfg.AllowAnyOrigin(); }); .. } }}
The UseCors middleware extension method accepts an action method to configure the different rules. For example, the previous code executes the AllowAnyOrigin method to allow calls from any website. In the same way, it is possible to define more restricting rules on a specific domain, ...
Read now
Unlock full access