设置前端跨域请求很简单,只需要两个步骤
1.安装package
Install-Package Microsoft.AspNet.WebApi.Cors
2.WebApiConfig类中,Register方法添加跨域方法:
var cors = new EnableCorsAttribute("*", "*", "*"); cors.SupportsCredentials = true; config.EnableCors(cors);
Copyright @ 2024 alun-chen Powered by .NET 9.0 on Kubernetes Powered by: .Text and ASP.NET Theme by: .NET Monster