Sunday, 11 August 2013

Get ASP.net username of Authenticated User and redirect

Get ASP.net username of Authenticated User and redirect

I am trying to redirect based on the username of authenticated users, and
if the name matches something, to redirect the page. But the code below
seems to just send "Admin" to the homepage, instead of the account page.
Is this even possible?
Protected Sub Page_Init(sender As Object, e As System.EventArgs)
Handles Me.Init
If User.Identity.IsAuthenticated Then
Dim CurrentUser As MembershipUser = Membership.GetUser()
If CurrentUser IsNot Nothing Then
If CurrentUser.IsApproved = False Or CurrentUser.IsLockedOut =
True Then
FormsAuthentication.SignOut()
FormsAuthentication.RedirectToLoginPage()
End If
If CurrentUser Is "Admin" Then
Response.Redirect("/account/")
End If
Response.Redirect("/home/")
End If
End If
End Sub

No comments:

Post a Comment