Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 回发和URL重写器_C#_Asp.net Membership_Urlrewriter - Fatal编程技术网

C# 回发和URL重写器

C# 回发和URL重写器,c#,asp.net-membership,urlrewriter,C#,Asp.net Membership,Urlrewriter,我遇到了一个有趣的问题,我碰到了一堵砖墙。我对实现表单身份验证并使用Intellegencia.Rewriter的登录页面有问题。身份验证在所有浏览器的localhost上都可以正常工作,但在服务器上,页面的回发特性似乎在IE9中丢失,但在Chrome中却可以正常工作。我在登录页面上的代码是: bool isAuthenticated = Membership.ValidateUser(username, password); string returnUrl = Server.

我遇到了一个有趣的问题,我碰到了一堵砖墙。我对实现表单身份验证并使用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;
            }
其中,AuthenticateServalid函数为:

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;

}
任何想法或解决方案都将不胜感激。问候,

医学博士