net core静态文件允许跨域访问。net core设置静态资源Access-Control-Allow-Origin*
电脑版发表于:2020/4/29 23:06
code:
//app.UseStaticFiles(); app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse = (c) => { c.Context.Response.Headers.Add("Access-Control-Allow-Origin", "*"); } });
注意把以前那个app.UseStaticFiles()注释掉,不然修改不会生效