【发布时间】:2011-05-19 14:08:16
【问题描述】:
- Asp.Net MVC 3
- FormsAuthentication(自定义)
- iPad MobileSafari
- iframe(同域)
在与 formsTicket.UserData 不兼容 MobileSafari(仅限 MoblieSafari)苦苦挣扎后,我发现 httpContext.User.Identity.Ticket.UserData 是 empty(在 MobileSafari 中,而不是其他)而原始的 FormsAuthentication HttpCookie 包含 正确的值?!?
怎么可能?!
代码:
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
瓦拉帕
PS:如果重要的话,我会在 iframe 中使用我网站的一个页面 - 同一个域。
【问题讨论】:
标签: cookies forms-authentication mobile-safari user-data