一般情况WebApi都是跨域请求,没有设置跨域一般会报以下错误 No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:48057' is therefore not allowed access. ASP.net Core 跨域有两种,全局和区域 全局跨域: 打开Startup.cs文件.在ConfigureServices方法中添加以下代码 1
验证环境: dotnet core 2.1/Asp.net core2.1 一.作用域在中间件层 配置的方式是在startup.cs文件Configure(IApplicationBuilder app, IHostingEnvironment env)方法中增加跨域配置.官方示例: // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <html> <head> <title>企业列表</title> </head> <body > </body> </html> <script type="text/javascript"> var webservic