我已经创建了 3 个文件夹来管理 ASP.NET 中的用户,并且我还创建了 3 个角色,分别名为官员、用户和管理员。现在基于以下代码,用户可以重定向到特定页面,但现在的问题是我可以'登录后看不到使用loginName添加的用户名 ,LoginStatus 会自动从注销更改为登录。似乎用户没有登录并要求再次登录。(有趣的问题......)
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
if (Membership.ValidateUser(Login1.UserName, Login1.Password))
{
//Perform setting cookie information
e.Authenticated = true;
if (Roles.IsUserInRole(Login1.UserName, "r_admin"))
{
Response.Redirect("admin/default.aspx");
}
if (Roles.IsUserInRole(Login1.UserName, "r_officer"))
{
Response.Redirect("~/officer/default.aspx");
}
if (Roles.IsUserInRole(Login1.UserName, "r_user"))
{
Response.Redirect("~/user/default.aspx");
}
}