One, the cross-domain processing in Core webapi
1. Cross-domain processing is almost always used when using the WEBAPI project
2.Core Webapi project with cross-domain cors processing, no need to add packages separately
3. Simple method of Use
Ii. Examples of Use
1. Cross-domain processing is enabled in the global configuration, named ' Any ', which can be accessed
void configureservices (iservicecollection services) { // Configure cross-domain processing services. Addcors (options = options. Addpolicy ("any", builder = { // allow host access to any source . Allowanymethod () . Allowanyheader () . Allowcredentials (); // Specify processing Cookies }); });}
2. Use the cross-domain rule of the corresponding name on the controller or the action's method note,
[Enablecors ("any")]
[Produces ("Application/json")] [Route ("Api/menu")] [Enablecors ("any")] // set up agents for cross-domain processing Public class Menucontroller:controller { }
Note: If specified on the controller, all action within the controller has a corresponding cross-domain limit.
Third, when cross-domain, the use of cookies
More:
ASP. NET Core Webapi get started (b) Simple example
ASP. NET Core Webapi Getting Started (i)
JSON serialization processing in ASP.
ASP. NET Core Webapi Getting Started (iii) cross-domain processing