C#WebService 出现Access-Control-Allow-Origin header is present on the requested resource无响应解决方法
来源:互联网 发布:阿里云 cdn 带宽限制 编辑:程序博客网 时间:2024/05/22 09:01
今天前端突然说调用我写的webservice挂掉了报错,一看错误信息是跨域的问题:
【XMLHttpRequest cannot load http://localhost:8018/WebService.asmx?op=UserLoginNo 'Access-Control-Allow-Origin' header is present on the requested resource. Origin http://localhost:8018/WebService.asmx?op=UserLogin' is therefore not allowed access】
然后检查了下,首先排除代码,最近没更新过,那就是服务器里面的设置的问题了,前几天服务器刚挂掉,客户重新安装的,检查下发现远程服务器的访问IP和 里面的本地IP不一致的
解决方法:
第一反应:由于是在JS里面调用的就 dataType: 'json', 改成dataType: 'jsonp', 但这样工作量会变大,因为JS里面的调用都的改
第二种方法:
在config里面加上
<system.webServer><httpProtocol><customHeaders><add name="Access-Control-Allow-Methods" value="OPTIONS,POST,GET"/><add name="Access-Control-Allow-Headers" value="x-requested-with"/><add name="Access-Control-Allow-Origin" value="*" />//表示允许所有来源进行跨域访问</customHeaders></httpProtocol></system.webServer>其他参考地址:
http://www.cnblogs.com/yangecnu/p/introduce-cross-domain.html
http://blog.csdn.net/qq_32786873/article/details/52170229
阅读全文
0 0
- C#WebService 出现Access-Control-Allow-Origin header is present on the requested resource无响应解决方法
- No 'Access-Control-Allow-Origin' header is present on the requested resource 的解决方法
- No 'Access-Control-Allow-Origin' header is present on the requested resource解决方法
- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin is therefore no
- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '***' is theref
- 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefor
- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '
- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin
- No 'Access-Control-Allow-Origin' header is present on the requested resource. 报错解决。
- 解决“No 'Access-Control-Allow-Origin' header is present on the requested resource”
- 解决“No 'Access-Control-Allow-Origin' header is present on the requested resource.”
- “No 'Access-Control-Allow-Origin' header is present on the requested resource”
- 报No 'Access-Control-Allow-Origin' header is present on the requested resource
- 跨域问题:No 'Access-Control-Allow-Origin' header is present on the requested resource.
- jquery ajax No 'Access-Control-Allow-Origin' header is present on the requested resource
- No 'Access-Control-Allow-Origin' header is present on the requested resource
- No 'Access-Control-Allow-Origin' header is present on the requested resource.
- No 'Access-Control-Allow-Origin' header is present on the requested resource
- jvm系列(一):java类的加载机制
- android真机通过monkey进行稳定性测试与压力测试
- 排序算法.md
- [Shell]test命令使用指南
- Running OpenBTS with the Nuand bladeRF on Ubuntu (The Definitive and Step by Step Guide)
- C#WebService 出现Access-Control-Allow-Origin header is present on the requested resource无响应解决方法
- 快速排序.md
- js 中的对象原型
- 单位班车手持刷卡终端,同时可作考勤、消费刷卡终端
- JSP页面参数传递时类型转换总结
- 数控机床安装调试中的传动比设置
- jvm系列(二):JVM内存结构
- 指针基础
- 沙盒防泄密(SDC)