开发者

Changing HttpContext.Current.User.Identity.Name after User is logged in

开发者 https://www.devze.com 2023-04-12 11:56 出处:网络
I\'m currently workin开发者_如何学Gog on a ASP MVC application. And was wondering if there is a way of changing HttpContext.Current.User.Identity.Name once the user has logged in.

I'm currently workin开发者_如何学Gog on a ASP MVC application. And was wondering if there is a way of changing HttpContext.Current.User.Identity.Name once the user has logged in.

I want to be able to do this to allow the user to change his/her username, and so need HttpContext.Current.User.Identity.Name to be changed once they have done that.

Any help would be great


I believe you can not do this:)

It is filled during authentication. Simpliest solution is when user changes username - log him out, and ask for login.

Update

It will work only with custom provider. If you are using standard one, i believe it can't be changed at all.

As an alternative solution you can try to do next: When user tries to change his name: 1. Create new user 2. abandon session 3. remove old user 4. change all data which related to user to a new account 5. log him in once again with new user.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号