J
Juan Puebla
Hi,
I try to redirect users to specific pages depending on roles:
If Membership.ValidateUser(TextBox1.Text, TextBox2.Text) Then
'Membership.ValidateUser(TextBox1.Text, TextBox2.Text) Then
Dim encryptedStr As String
Dim cookie As HttpCookie
Dim ticket As New FormsAuthenticationTicket(1, TextBox1.Text,
Now(), Now().AddMinutes(60), False, "IdCliente")
encryptedStr = FormsAuthentication.Encrypt(ticket)
cookie = New HttpCookie(FormsAuthentication.FormsCookieName,
encryptedStr)
Response.Cookies.Add(cookie)
If Roles.IsUserInRole("Parents") Then
Response.Redirect("AppsHtml/Roles/Parents.aspx", True)
ElseIf Roles.IsUserInRole("Director") Then
Response.Redirect("AppsHtml/Roles/Directors.aspx", True)
ElseIf Roles.IsUserInRole("Professor") Then
Response.Redirect("AppsHtml/Roles/Professors.aspx", True)
End If
Else
Label3.Visible = True
End If
When I try this I fill Login and password in textboxes and press the button.
I have to press the button twice to get redirected to the page for the role.
It seems that I need a round trip to get the user authenticated.
Any help?
thanks
Juan
I try to redirect users to specific pages depending on roles:
If Membership.ValidateUser(TextBox1.Text, TextBox2.Text) Then
'Membership.ValidateUser(TextBox1.Text, TextBox2.Text) Then
Dim encryptedStr As String
Dim cookie As HttpCookie
Dim ticket As New FormsAuthenticationTicket(1, TextBox1.Text,
Now(), Now().AddMinutes(60), False, "IdCliente")
encryptedStr = FormsAuthentication.Encrypt(ticket)
cookie = New HttpCookie(FormsAuthentication.FormsCookieName,
encryptedStr)
Response.Cookies.Add(cookie)
If Roles.IsUserInRole("Parents") Then
Response.Redirect("AppsHtml/Roles/Parents.aspx", True)
ElseIf Roles.IsUserInRole("Director") Then
Response.Redirect("AppsHtml/Roles/Directors.aspx", True)
ElseIf Roles.IsUserInRole("Professor") Then
Response.Redirect("AppsHtml/Roles/Professors.aspx", True)
End If
Else
Label3.Visible = True
End If
When I try this I fill Login and password in textboxes and press the button.
I have to press the button twice to get redirected to the page for the role.
It seems that I need a round trip to get the user authenticated.
Any help?
thanks
Juan