简体   繁体   中英

ASP.net Form Authentication cookie is missing

Background: I am using javascript to communicate with my WCF service. The session of the service is in asp compatible mode. I call /publicService.svc/ajax/logon to logon, and try to retreive /User/Home.aspx by ajax.

Problem: On local dev machine (win7), and my test server (2003 + IIS6 + .net4), it works with no problem. But on the production server, the logon request will succeed but authentication will not work.

The web.config:

<authentication mode="Forms">
    <forms loginUrl="~/Account/Login.aspx" timeout="2880" name="party"  />
</authentication>

Some finding: I found the authentication cookie is missing if I access the production server.

On a working server:

logon: 
   Request Cookies: ASP.NET_SessionId: xxxxx
   Response Cookies: party: xxxxx
Home.aspx:
   Request Cookies: ASP.NET_SessionId: xxxxx
                    party: xxxxx

So far so good, but on the problemetic server:

logon: 
   Request Cookies: ASP.NET_SessionId: xxxxx
   Response Cookies: party: xxxxx
Home.aspx:
   Request Cookies: ASP.NET_SessionId: xxxxx

The authentication cookie is missing here. Therefore the authentication is not working.

What's the possible reason of this? All the requests are under same domain so no cross-domain issue here

This is really stupid! The server time is configured as one year ago and when I correct it everything starts to work

try adding this:

ticketCompatibilityMode="Framework40"

to make it

<authentication mode="Forms">
    <forms loginUrl="~/Account/Login.aspx" timeout="2880" name="party"  
    ticketCompatibilityMode="Framework40"/>
</authentication>

according to msdn "A value that indicates whether to use Coordinated Universal Time (UTC) or local time for the ticket expiration date."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM