- ASP.NET MVC 3
- FormsAuthentication(自定义)
- iPad MobileSafari
- iframe(同域)
在努力formsTicket.UserData
不使用MobileSafari(仅 MoblieSafari)之后,我发现那httpContext.User.Identity.Ticket.UserData
是空的(在 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!
...
}
}
任何线索都会有所帮助!
瓦拉帕
_
PS:如果重要的话,我会在 iframe 中使用我网站的页面 - 相同的域。