.net core 跨域

  public void ConfigureServices(IServiceCollection services)

  #region 配置跨域
            //配置跨域处理
            services.AddCors(options => options.AddPolicy("CorsPolicy",
             builder =>
             {
                 builder.AllowAnyMethod()
                     .SetIsOriginAllowed(_ => true)
                     .AllowAnyHeader()
                     .AllowCredentials();
             }));
            #endregion

 public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

         #region 配置跨域
            app.UseCors("CorsPolicy");
         
            #endregion

 

posted @ 2021-08-26 08:50  enych  阅读(136)  评论(0编辑  收藏  举报