使用框架 4.0
场景 1:
使用 Live.com 登录。
在 Live.com FormsAuthenticationTicket 中不为空,ticket.name 是我的用户 ID。
在 Local.com FormsAuthenticationTicket 中为空。
我不知道这里缺少什么。
场景 2:
使用 Local.com 登录。
在 Local.com FormsAuthenticationTicket 中不为空,ticket.name 是我的用户 ID。
在 Live.com FormsAuthenticationTicket 中为空。
我的机器配置设置在本地和实时站点中是相同的
目标框架是 4.0
ApplicationAuthenticate_request 如下:
HttpCookie AuthCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
FormsAuthenticationTicket ticket = null;
if (AuthCookie != null)
{
try
{
ticket = FormsAuthentication.Decrypt(AuthCookie.Value);
if (ticket != null && ticket.Name != null)
Response.Write(ticket.Name);
}
catch (Exception ex11)
{
string sErr = ex11.Message + ex11.StackTrace;
}
}
登录代码如下
authenticationTicket = new FormsAuthenticationTicket(UserId, mPersistant, 30);
//FormsAuthenticationTicket authenticationTicketV1 = new FormsAuthenticationTicket(1, userGuid,DateTime.Now, DateTime.Now.AddMinutes(30), lPersistant, "User");
string authEncrypt = FormsAuthentication.Encrypt(authenticationTicket);
FormsAuthenticationTicket authTickChk = FormsAuthentication.Decrypt(authEncrypt);
bool bChk = authTickChk.Name.Equals(authenticationTicket.Name);
// Create form identity from FormsAuthenticationTicket.
id = new FormsIdentity(authenticationTicket);
// Set the Context User
HttpContext.Current.User = this;