是不同的用户访问不同的页面,根据他们的角色

http://forums.asp.net/p/2042577/5886687.aspx?p=True&t=635634505624233224

1. 在Login1_LoggedIn事件里面

protected void Login1_LoggedIn(object sender, EventArgs e)

{

    {

             if (Roles.IsUserInRole(Login1.UserName, "Admin"))

            Response.Redirect("~/Admin/Default.aspx");

        else if (Roles.IsUserInRole(Login1.UserName, "User"))

            Response.Redirect("~/User/Default.aspx");

    }

}
View Code


2. 在 Login1_Authenticate事件里面

protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)

    {

        if (Membership.ValidateUser(Login1.UserName, Login1.Password))

        {

            if (Roles.IsUserInRole(Login1.UserName, "Admin"))

            {

               Response.Redirect("~/Admin/Default.aspx");

            }

            else if (Roles.IsUserInRole(Login1.UserName, "User"))

            {

               Response.Redirect("~/User/Default.aspx");

            }               

        }

    }
View Code

 

你可能感兴趣的:(用户)