今天使用 weiapi 的模拟器调试程序的时候,发现使用jquery的异步方法调用的内容不显示 查看后台报错:
XMLHttpRequest cannot
load http://localhost:22222/api/User/Login?strUser=admin&strPwd=123456. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:11111' is therefore not allowed access.
解决方法: 在 http://localhost:22222 项目的 Web.config 添加一段
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Methods" value="OPTIONS,POST,GET"/>
<add name="Access-Control-Allow-Headers" value="x-requested-with,content-type"/>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
转载请注明原文地址: https://ju.6miu.com/read-1125179.html