1、服务端的web.config里配置如下:
代码:
<!--跨域配置-->
<add key="cors:allowedMethodes" value="*" />
<add key="cors:allowedOrigin" value="*" />
<add key="cors:allowedHeaders" value="*" />
代码:
#region 跨域配置
var allowedMethods = ConfigurationManager.AppSettings["cors:allowedMethodes"];
var allowedOrigin = ConfigurationManager.AppSettings["cors:allowedOrigin"];
var allowedHeaders = ConfigurationManager.AppSettings["cors:allowedHeaders"];
var Cors = new EnableCorsAttribute(allowedOrigin, allowedHeaders, allowedMethods)
{
SupportsCredentials = true
};
config.EnableCors(Cors);
#endregion