跨域XMLHtt prequest不处理ASP.NET_SessionId饼干 - 可能是什么情况? [英] Cross-origin XMLHttpRequest does not process ASP.NET_SessionId cookies - what could be the case?

查看:96
本文介绍了跨域XMLHtt prequest不处理ASP.NET_SessionId饼干 - 可能是什么情况?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题在标题挣扎了已经两天没有成功。我有需要基本身份验证的ASP.NET MVC 3 REST服务器。我想写的JS API访问使用XMLHHtt prequest在AJAX方式这台服务器。

I'm struggling with the problem in title for already couple of days with no success. I have an ASP.NET MVC 3 REST server which requires basic authentication. I want to write JS API accessing this server in AJAX way using XMLHHttpRequest.

有关响应的任何HTTP请求,包括AJAX那些服务器添加设置Cookie:ASP.NET_SessionId =<这里的session id取代;路径= /;仅Http头- 没关系。但似乎设置Cookie标头不处理浏览器以任何方式 - 所以即使我做下一个请求使用相同的XMLHtt prequest对象的cookie设置不正确,我不能保持会话。我可能是做错了?

For response to any http request including AJAX ones server adds "Set-Cookie: ASP.NET_SessionId=<session id here>; path=/; HttpOnly" header - that's ok. But it seems that Set-Cookie header is not processed by browser in any way - so even if I do next request with the same XMLHttpRequest object the cookie is not set properly and I can't maintain the session. What I might be doing wrong?

我的剧本已经在Firefox 6和Safari 5的测试和我有同样的问题发生在这两个浏览器。

My script has been tested in Firefox 6 and Safari 5 and I have the same problem happening in both browsers.

推荐答案

虽然我还没有发现任何相关的解决原来的问题,我已经能够通过实现我的ASP.NET会话自定义传输,克服它,鉴定文物。

Although I haven't found any relevant solution to the original problem, I've been able to overcome it by implementing my custom transport for ASP.NET session and authentication artifacts.

在一般情况下,在我的解决方案所有的ASP.NET工件都从服务器转移到客户端为JSON串附加到响应的内容,并且从客户端至服务器 - 定制HTTP标头。

In general, in my solution all ASP.NET artifacts are transfered from server to clients as JSON string appended to response content, and from clients to server - as custom HTTP headers.

不知道,我不这样做,重新发明了轮子,但至少它的工作原理...

Not sure that I haven't reinvented the wheel by doing that, but at least it works...

这篇关于跨域XMLHtt prequest不处理ASP.NET_SessionId饼干 - 可能是什么情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆