2011-05-19 26 views
2
  • Asp.Net MVC 3
  • FormsAuthentication(自定义)
  • iPad的MobileSafari
  • IFRAME(同一域)

formsTicket.UserData没有经过挣扎与MobileSafari(仅MoblieSafari)工作,我发现,这是httpContext.User.Identity.Ticket.UserData(在MobileSa fari,而不是其他人)与原FormsAuthentication 的HttpCookie包含正确的价值观?!?FormsAuthentication:失去的UserData(但在饼干)

这怎么可能?

代码:

public void UpdateContext() 
{ 
    if (httpContext.User.Identity is FormsIdentity) 
    { 
     // Get Forms Identity From Current User 
     FormsIdentity id = (FormsIdentity)httpContext.User.Identity; 
     // Create a custom Principal Instance and assign to Current User (with caching) 
     HttpCookie cookie = HttpContext.Current.Request.Cookies.Get(FormsAuthentication.FormsCookieName); 
     FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value); 

     var cookieUserData = ticket.UserData; // not empty 
     var httpContextIdentiyUserData = id.Ticket.UserData; // empty! 
     ... 
    } 
} 

任何线索将是有益的!

了Lg
Warappa

PS:如果它的事项,我用我的网站的页面中的iframe - 同一个域。

+0

找到这个 http://stackoverflow.com/questions/4158550/problem-with-asp-net-forms-authentication-when-using-iphone-uiwebview – 2012-01-09 09:22:57

回答

1

所以这个问题是以下几点:
此错误出现当我登录出来,访问的页面做了history.back()

寻找与提琴手交通我一看,是Asp.Net使用cookie的认证模式,所以认证是编码到URL。现在,history.back()发生时,该URL指向注销URL与在我身边现在无效的认证信息 ...讨厌的错误。

强制Asp.Net使用Cookie的伎俩!

了Lg
warappa