我正在尝试调用 WebAPI 方法来获取一些数据,但是Cross-Origin Read Blocking (CORB) blocked cross-origin response https://localhost:44332/api/Controller/Action with MIME type text/html.即使我在我的 ConfigureServices 方法中启用了 CORS 并在启动时使用了 Configure 方法中的策略,它也会抛出一个public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddPolicy("AllowAll", builder => { builder .WithOrigins("http://localhost:4200/") .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials(); }); }); services.AddMvc(); }public void Configure(IApplicationBuilder app, IHostingEnvironment env) { ..... app.UseCors("AllowAll"); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); });}原因可能是什么?
- 2 回答
- 0 关注
- 663 浏览
添加回答
举报
0/150
提交
取消