1

レンガの壁にぶつかったという興味深い問題があります。フォーム認証を実装し、Intellegencia.Rewriter を使用するログイン ページに問題があります。認証はすべてのブラウザーの localhost で正常に機能しますが、サーバーでは、ページのポストバックの性質が IE9 で失われているように見えますが、Chrome では正常に機能します。ログインページにあるコードは次のとおりです。

bool isAuthenticated = Membership.ValidateUser(username, password);
        string returnUrl = Server.HtmlDecode(Request["ReturnUrl"]);
        lblLoggedIn.Text = Page.IsPostBack.ToString();
        if (isAuthenticated && 
                            Thread.CurrentPrincipal.Identity.Name == "")
            {
                HttpContext.Current.User = AuthenticateUserIfValid(username);
                Thread.CurrentPrincipal = HttpContext.Current.User;
            }

関数 AuthenticateUserIfValid は次のとおりです。

public Principal.GenericPrincipal AuthenticateUserIfValid(string username)
{
    MembershipUser mpc = Membership.FindUsersByName(username)[username];
    string[] roles = Roles.GetRolesForUser(mpc.UserName);
    string strRoles = "";

    foreach (string role in roles) 
                   strRoles += strRoles != "" ? "," + role : role;

    FormsAuthenticationTicket fat = 
                    new FormsAuthenticationTicket(1, mpc.UserName.ToString(),
                 DateTime.Now, 
                           DateTime.Now.AddMinutes(30), 
                           true, 
                           strRoles, 
                           FormsAuthentication.FormsCookiePath);

    Response.Cookies.Add(
                        new HttpCookie(FormsAuthentication.FormsCookieName,
                   FormsAuthentication.Encrypt(fat)));

    Response.Cookies.Add(new HttpCookie("UserRoles", strRoles));

    Principal.GenericPrincipal myPrincipal;
    Principal.GenericIdentity myIdentity = 
                     new Principal.GenericIdentity(mpc.UserName);
    myPrincipal = new Principal.GenericPrincipal(myIdentity, roles);
    return myPrincipal;

}

どんな考えや解決策も大歓迎です。よろしく、

MD

4

0 に答える 0