什么在吃我的饼干?!Cookie不会在asmx调用中被转移

What is eating my cookie?! Cookie does not get transferred in asmx call

本文关键字:asmx 调用 转移 Cookie 我的 饼干 什么      更新时间:2023-09-26

我这里有一个(浏览器)cookie问题。

我有一个Sharepoint页面(http://myServer:24628/sites/myApp/myDocumentLibrary/test.aspx)。当页面被请求时,我可以在请求头中看到(使用firebug)有一个ASP。NET_SessionId饼干。

请求头:

Host: myServer:24628
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: keep-alive
Cookie: ASP.NET_SessionId=2vhaxii0hxqeazii2sgw3q55; WSS_KeepSessionAuthenticated=24628
If-Modified-Since: Thu, 27 Oct 2011 15:41:15 GMT
Cache-Control: max-age=0

响应标头:

Cache-Control: private, max-age=0
Content-Length: 210604
Content-Type: text/html; charset=utf-8
Expires: Wed, 12 Oct 2011 15:41:24 GMT
Last-Modified: Thu, 27 Oct 2011 15:41:24 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
MicrosoftSharePointTeamServices: 12.0.0.6421
X-AspNet-Version: 2.0.50727
Set-Cookie: WSS_KeepSessionAuthenticated=24628; path=/
http%3A%2F%2FmyServer%3A24628%2Fsites%2FmyApp%2FDiscovery=WorkspaceSiteName=UG9ydGFs&WorkspaceSiteUrl=aHR0cDovL3dlYmFwcDAxOjI0NjI4L3NpdGVzL251bnRpbw==&WorkspaceSiteTime=MjAxMS0xMC0yN1QxNTo0MTozMQ==; expires=Sat, 26-Nov-2011 16:41:31 GMT; path=/_vti_bin/Discovery.asmx
Date: Thu, 27 Oct 2011 15:41:31 GMT

页面加载后,我发出asmx请求(POST):

请求头:

Host    myServer:24628
User-Agent  Mozilla/5.0 (Windows NT 6.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
Accept  text/javascript, text/html, application/xml, text/xml, */*
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection  keep-alive
X-Requested-With    XMLHttpRequest
X-Prototype-Version 1.7
Content-Type    application/json; charset=UTF-8
Referer http://myServer:24628/sites/myApp/myDocumentLibrary/test.aspx
Content-Length  42
Cookie  WSS_KeepSessionAuthenticated=24628

在调用asmx之前,我警告了'ASP. js '的值。NET_SessionId的饼干。它在那里,它的价值是正确的。

在通知。我需要检索cookie值以便能够运行一些逻辑。这显然是失败的。
这是怎么回事?

现在,

    下面是通知服务的url:http://myServer:24628/sites/myApp/_layouts/WebServices/NotifierServices.asmx/Notify(所以相同的域名,对吗?)
  • 它发生在IE/FF(没有尝试其他浏览器)
  • 在我们的生产服务器上运行良好
  • web服务明确地(有意地)将EnableSession设置为false

马努。

你的cookie没有被发送,因为两个请求的Host字段不相同:

主持人:webapp01:24628

主机myServer: 24628

javascript确实是从另一个位置加载的。正如Chris Lively在评论我的问题时建议的那样

覆盖所有基地,你有[WebMethod(EnableSession = true)]吗?

这只发生在IE吗?我只在IE上看到过这个,必须添加一个P3P头条目,但这是跨域SSO解决方案。