I am trying to create a website where people can change their userName from an update form. When user enter to the site it will grab the userName and role. These values will be assigned to the HttpContext.Current.user in Global.asax page. The problem is that whenever I update the userName to the database and then return to the defualt.aspx page it couldn't retrieve user's information anymore, because I have updated the userName in the database. The Global.asax page still uses the old Httpcontext.Current.User values to retrieve data from the database, where the userName doesn't exsit anymore.
I would like to know how could I update my new userName to the HttpContext in order to retrieve data back to the web pages during run time?
I have applied the following codes to Global.asax and update.aspx
Global.asax (works fine in here)
' -- Add the roles to the User Principal
HttpContext.Current.User = New GenericPrincipal(User.Identity, roleListArray)
update.aspx (doesn't seems like it's updating at all!!!)
' -- Add the roles to the User Principa
Dim MyIdentity As New GenericIdentity(txtEmail.Text)
HttpContext.Current.User = Nothing
HttpContext.Current.User = New GenericPrincipal(MyIdentity, roleListArray)