Asp. Net Core2.0 allows cross-origin request settings, asp. netcore2.0
1. services
1 /// <summary> 2 // 3 /// </summary> 4 /// <param name = "services"> </param> 5 public void ConfigureServices (IServiceCollection services) 6 {7 # region allows cross-origin requests 8 services. addCors (options => 9 {10 options. addPolicy ("CorsPolicy", 11 builder => builder12. allowAnyOrigin () 13. allowAnyMethod () 14. allowAnyHeader () 15. allowCredentials (); 16}); 17 # endregion18}
2. app
1 // <summary> 2 // 3 /// </summary> 4 /// <param name = "app"> </param> 5 // <param name = "env"> </param> 6 // <param name = "loggerFactory"> </param> 7 public void Configure (IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) 8 {9 # region allows cross-origin requests to 10 apps. useCors (builder => builder. allowAnyOrigin (). allowAnyMethod (). allowAnyHeader (). allowCredentials (); 11 # endregion12}