您好,欢迎来到96游戏网。
搜索
您的当前位置:首页asp.net(C#)跨域及跨域写Cookie问题

asp.net(C#)跨域及跨域写Cookie问题

来源:96游戏网


解决方法是:
代码如下:

//www.B.com里的被调用的页面需要写P3P头,从而解除IE对写Cookie的阻止
context.Response.AddHeader("P3P", "CP=CAO PSA OUR");

//www.A.com里通过ajax调用www.B.com里的内容时,是跨域访问,需要使用jsonp,为配合其工作需要添加下面两句,生成jsonp返回
context.Response.ContentType = "text/plain";
context.Response.Write(string.Format("{0}('OK')", context.Request["callback"]));

代码如下:


//jsonp调用进行跨域访问
jQuery.ajax({
url: url,
type: 'GET',
data: data,
dataType: 'jsonp',
success: function (data) {
window.location.href = toURL;
}
});

Copyright © 2019- 9603.com.cn 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务