您的位置: 首页 > 文章 > webapi跨域解决方案 webapi跨域解决方案 分类: 文章 • 2022-10-02 09:12:52 服务器添加响应头跨域 1.进入服务器端IIS,打开相应头设置 添加响应头 Access-Control-Allow-Origin:* Access-Control-Allow-Methods:* 服务器端代码跨域 选择工具,管理解决方案的NuGet程序包 搜索并安装 Microsoft.AspNet.WebApi.Cors 在WebApiConfig.cs的Register函数中增加 config.EnableCors(new EnableCorsAttribute("*", "*", "*"));