C# 如何将guest从登录重定向到guest.aspx

C# 如何将guest从登录重定向到guest.aspx,c#,forms,.net-3.5,login,response.redirect,C#,Forms,.net 3.5,Login,Response.redirect,我有一个管理员和一个来宾用户 当管理员登录时,他应该被重定向到default.aspx,但是如果来宾登录,他应该被重定向到guest.aspx页面。。。目前它被重定向到Default.aspx 这是我的密码 web.config authentication mode="Forms"> <forms loginUrl="Login.aspx" protection="All" name="Cookie" timeout="120" path="/" slidingExpira

我有一个管理员和一个来宾用户

当管理员登录时,他应该被重定向到default.aspx,但是如果来宾登录,他应该被重定向到guest.aspx页面。。。目前它被重定向到Default.aspx

这是我的密码

web.config

authentication mode="Forms">
    <forms loginUrl="Login.aspx" protection="All" name="Cookie" timeout="120" path="/" slidingExpiration="true"
       defaultUrl="Default.aspx">
    </forms>
  </authentication>
如何为来宾获取另一个URL


有什么建议吗??谢谢。

在您的来宾部分替换:

// Redirect the user to the originally requested page 
Response.Redirect(FormsAuthentication.GetRedirectUrl(UserName.Text, false)); 
与:


如果您总是想重定向到特定页面,为什么在这两种情况下都要重定向到FormsAuthentication.GetRedirectUrl(UserName.Text,false)。您可以使用Response.Redirect(adminPage)或Response.Redirect(guestPage)为变量提供所需的值。我之所以发表评论,是因为我想我读这个问题的方式与你的意图不同,我认为是出于身份验证.GetRedirectUrl(UserName.Text,false);需要发送用于生成令牌密钥的用户名。。。但是我不确定。。我还认为GetRedirectUrl可以获取存储在某个字符串变量中的所需Url…它无法获取默认页面中的管理员角色///以及响应.Redirect(FormsAuthentication.GetRedirectUrl(UserName.Text,false));我能够得到用户的角色…应该是“guest.aspx”。我假设您的来宾没有任何角色,是吗?我不确定您是否可以使用表单身份验证自动获取角色。您不需要使用Windows Auth来提供这些信息吗?听起来你想用windows auth创建一个混合表单?
// Redirect the user to the originally requested page 
Response.Redirect(FormsAuthentication.GetRedirectUrl(UserName.Text, false)); 
// Redirect the user to the originally requested page 
FormsAuthentication.SetAuthCookie(UserName.Text, false)
Response.Redirect("guest.aspx", true);