问题
I'm having a (browser) cookie issue here.
I have a Sharepoint page (http://myServer:24628/sites/myApp/myDocumentLibrary/test.aspx). When the page is requested, I can see in the request headers (using firebug) that there's a ASP.NET_SessionId cookie.
Request headers:
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
Response headers:
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
After the page loads I make an asmx request (POST):
Request headers:
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
Right before making the asmx call, I alert the value of the 'ASP.NET_SessionId' cookie. It's there and it's value is correct.
In the notify.asmx call I need to retrieve the cookie value to be able to run some logic. This obviously fails.
What is going on here?
Ow yea,
- here's the url of the Notify service: http://myServer:24628/sites/myApp/_layouts/WebServices/NotifierServices.asmx/Notify (so the same domain, right?)
- it's happening on IE / FF (didn't try other browsers)
- on our production server it's working fine
- the webservice has explicitly (intentionally) set EnableSession on false
Manu.
回答1:
Your cookie isn't sent because the Host field is not the same on the two requests:
Host: webapp01:24628
Host myServer:24628
回答2:
The javascript was indeed loaded from a different location. As Chris Lively suggested in a comment on my question.
回答3:
Covering all bases, do you have [WebMethod(EnableSession = true)]
?
Is this only happening in IE? Have seen this with IE only, had to add a P3P header entry, but that was for cross-domain SSO solution.
来源:https://stackoverflow.com/questions/7918697/what-is-eating-my-cookie-cookie-does-not-get-transferred-in-asmx-call