ASP.NET Ajax 跨域问题最佳解决方案
来源:互联网 发布:做彩票网络销售怎么样 编辑:程序博客网 时间:2024/05/17 08:11
通过设置Access-Control-Allow-Origin来实现跨域。
例如:客户端的域名是client.runoob.com,而请求的域名是server.runoob.com。
如果直接使用ajax访问,会有以下错误:
XMLHttpRequest cannot load http://server.runoob.com/server.php. No 'Access-Control-Allow-Origin' header is present on the requested resource.Origin 'http://client.runoob.com' is therefore not allowed access.
添加如下代码在ashx中
Response.AppendHeader("Access-Control-Allow-Origin", "*")
Response.AppendHeader("Content-type", "application/json")
0 0
- ASP.NET Ajax 跨域问题最佳解决方案
- PHP Ajax 跨域问题最佳解决方案
- PHP Ajax 跨域问题最佳解决方案
- Ajax 跨域问题最佳解决方案
- PHP Ajax 跨域问题最佳解决方案
- PHP Ajax 跨域问题最佳解决方案
- PHP Ajax 跨域问题最佳解决方案
- PHP Ajax 跨域问题最佳解决方案
- PHP Ajax 跨域问题最佳解决方案
- PHP Ajax 跨域问题最佳解决方案
- PHP Ajax 跨域问题最佳解决方案
- PHP Ajax 跨域问题最佳解决方案
- PHP Ajax 跨域问题最佳解决方案
- PHP Ajax 跨域问题最佳解决方案
- PHP Ajax 跨域问题最佳解决方案
- PHP Ajax 跨域问题最佳解决方案
- PHP Ajax 跨域问题最佳解决方案
- PHP Ajax 跨域问题最佳解决方案
- SSH相关
- makefile使用规则详解
- 第020讲 仿sohu
- ZipHelper压缩解压缩
- 【数据结构】二叉排序树小礼包(对splay,Treap,SBT的理解,例题,代码)
- ASP.NET Ajax 跨域问题最佳解决方案
- HTM-16.2代码(5)——predInterSearch
- 关于Google protobuf的总结
- Java 中包的概念,常量,静态与继承
- 第021 问题
- 第022讲 可爱屋首页 浏览器兼容
- 第023 动态网页技术介绍 php基础
- 2016/12/27记一件有意思的事情
- Android开发事件传递机制详解