2
  • 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 中使用我网站的页面 - 相同的域。

4

1 回答 1

2

所以问题如下:
我注销并访问一个执行history.back().

查看我看到的 Fiddler 的流量,Asp.Net 使用cookieless 身份验证模式,因此身份验证被编码到 url中。现在,当history.back()发生这种情况时,该 url 指向带有现在无效身份验证信息的注销 url ......我身边的讨厌的错误。

强制 Asp.Net 使用 cookie 就成功了!


华拉巴

于 2011-05-20T08:33:48.460 回答