我希望应用程序将用户重定向到不同的主页,这取决于他们的角色。它目前正在为2个用户工作,使用以下IF?
If Request.IsAuthenticated AndAlso User.IsInRole("Staff") = True Then
Response.Redirect("~/About.aspx")
ElseIf Request.IsAuthenticated AndAlso User.IsInRole("HR") = False Then
Response.Redirect("~/HR\HRCompanyNavigation.aspx")
End If我如何才能让它在2个以上的用户角色中工作?
发布于 2012-01-23 19:28:30
像这样的东西?这可能适用于更简单的场景。但您应该记住,如果用户具有多个角色,则这是一个弱构造。
If Request.IsAuthenticated AndAlso User.IsInRole("Staff") = True Then
Response.Redirect("~/About.aspx")
ElseIf Request.IsAuthenticated AndAlso User.IsInRole("HR") = True Then
Response.Redirect("~/HR\HRCompanyNavigation.aspx")
ElseIf Request.IsAuthenticated AndAlso User.IsInRole("ThirdRole") = True Then
Response.Redirect("~/ThirdFolder\ThirdPage.aspx")
End Ifhttps://stackoverflow.com/questions/8970857
复制相似问题