Change HttpContext.Current.User.Identity.Name after user login

I am currently working on an ASP MVC application. And it was interesting if there is a way to change HttpContext.Current.User.Identity.Name after user login.

I want to be able to do this so that the user can change their username, and therefore I need to change the HttpContext.Current.User.Identity.Name after they have done this.

Any help would be great

+4
source share
1 answer

I believe that you cannot do this :)

It is populated during authentication. The simplest solution - when the user changes the username - log out and ask to log in.

Update

It will only work with a custom provider. If you use the standard, I believe that it cannot be changed at all.

As an alternative solution, you can try to do the following: When a user tries to change his name: 1. Create a new user 2. Cancel the session 3. Delete the old user 4. Change all the data associated with the user to a new account 5. Write it down again with a new user.

+1
source

All Articles