Hi, this is my first time posting in here. Hopefully I post my thread in the right place.
I am trying to implement login page using Form Authentication in ASP.net using vb code.I follow the steps in How To Implement Forms-Based Authentication in Your ASP.NET Application by Using Visual Basic .NET. I created a function in login page :
and call it in btnLogIn_Click
and in masterpage page_load , the usename is displayed in the welcome message
Things works fine and i can get the username display in label using the RedirectFromLoginPage method.
However, I found out that the RefirectFromLoginPage method is not suitable because i need get more user data like UserName, Fullname and RoleCode. Also, i would to display the user's fullname to instead of usename in welcome message. I was told this can be done using FormsAuthenticationTicket method to store addictional user data. Do i need to create a user data class to store the user data and then use it in the FormAuthenticationTicket? If yes, how should i do it? I have been scratching my head several days in googling to get a proper guide to do this,but i still cannot find out the solution.
Please can anyone help me? This is my first project in web application and I am quite lost now :ambivalence:, your help is much appreciated. Thank you.
I am trying to implement login page using Form Authentication in ASP.net using vb code.I follow the steps in How To Implement Forms-Based Authentication in Your ASP.NET Application by Using Visual Basic .NET. I created a function in login page :
VB.NET:
Private Function ValidateUser(ByVal strUsername As String, ByVal strPassword As String) As Boolean
VB.NET:
Protected Sub btnLogIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogIn.Click
If ValidateUser(txtUserName.Text, txtPassword.Text) = True Then
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, chkPersistCookie.Checked)
Response.Redirect("MaintainUsers.aspx", True)
Else
Response.Redirect("Login.aspx", True)
End If
and in masterpage page_load , the usename is displayed in the welcome message
VB.NET:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If HttpContext.Current.User.Identity.IsAuthenticated Then
Me.lblWelcomeMessage.Text = "Welcome," + " " + HttpContext.Current.User.Identity.Name
End If
End Sub
Things works fine and i can get the username display in label using the RedirectFromLoginPage method.
However, I found out that the RefirectFromLoginPage method is not suitable because i need get more user data like UserName, Fullname and RoleCode. Also, i would to display the user's fullname to instead of usename in welcome message. I was told this can be done using FormsAuthenticationTicket method to store addictional user data. Do i need to create a user data class to store the user data and then use it in the FormAuthenticationTicket? If yes, how should i do it? I have been scratching my head several days in googling to get a proper guide to do this,but i still cannot find out the solution.
Please can anyone help me? This is my first project in web application and I am quite lost now :ambivalence:, your help is much appreciated. Thank you.