No Access-Control-Allow-Origin ),
Preface:
Download ASP. the NET Core 2.x + Angular template project is independently deployed on the Web API and angular frontend in a ReStful architecture. After I deploy them separately in IIS, the front-end access API will generate cross-origin access restriction. By checking the Code, in fact, the TTL framework comes with cross-origin access settings, you only need to configure it, as shown in the following steps:
1. IIS deployment
Create a project using the template on the ABC official website, and then package the frontend and backend programs and release them to IIS:
My backend is released to: http: // localhost: 8060/
My front-end is released to: http: // localhost: 8080/
F12 error does not Allow cross-Origin access: Response to preflight request doesn't pass Access control check: No 'access-Control-Allow-origin' header is present on the requested resource. origin 'HTTP: // localhost: 100' is therefore not allowed access.
Ii. configuration instructions
Check that the Code has two configurations:
1. Configure the front-end in src/assets/appconfig. json
{ "remoteServiceBaseUrl": "http://localhost:8060", "appBaseUrl": "http://localhost:8080"}
RemoteServiceBaseUrl
2. Configure the backend in the Host project appsettings. json
"App": { "ServerRootAddress": "http://localhost:8060/", "ClientRootAddress": "http://localhost:8080/", "CorsOrigins": "http://localhost:8080/" }
ClientRootAddress is configured for the client site,CorsOrigins is configured to allow cross-origin client sites, Multiple can be separated by commas, and configured in Startup. cs.
// Configure CORS for angular2 UIservices.AddCors(options =>{ options.AddPolicy(DefaultCorsPolicyName, builder => { // App:CorsOrigins in appsettings.json can contain more than one address separated by comma. builder .WithOrigins(_appConfiguration["App:CorsOrigins"].Split(",", StringSplitOptions.RemoveEmptyEntries) .Select(o => o.RemovePostFix("/")) .ToArray()) .AllowAnyHeader() .AllowAnyMethod(); });});
3. Run
Access to the client again after configuration is successful
Blog: http://www.cnblogs.com/donaldtdz/p/7882316.html if you want to deploy the front-end Integration together