我有以下代码:
//redirect based on whether the user is admin, company owner, or blog owner
Dim userRole As String = Roles.GetRolesForUser(Membership.GetUser.UserName)(0)
Debug.Print(userRole)
If userRole Is "Administrator" Then
Return RedirectToAction("Index", "Company")
Else
Return RedirectToAction("Index", "Home")
End If
userRole 的值输出“Administrator”,我将其与“Administrator”进行比较,但它不会重定向到 Company 控制器,而是会转到“Home”。
我怎样才能解决这个问题?谢谢!
注意:我也试过这个,但它也没有执行重定向:
If String.Compare(userRole, "Administrator") Then