HttpContext.Current.User.Identity.Name is always string.Empty

后端 未结 7 836
清歌不尽
清歌不尽 2020-12-01 05:21

Hi I use a custom MembershipProvider.

I want to know the current username during an application scenario, but when I try accessing HttpContext.Current.User.Identity.

7条回答
  •  再見小時候
    2020-12-01 06:15

    The value of HttpContext.Current.User.Identity.Name is set by the call to RedirectFromLoginPage. You can get the current user id from HttpContext.Current.User.Identity.Name once you are redirected to a new page. I'm not sure why you would need to access the user name through the User property in this context, couldn't you just use the value contained in tbUsername.Text?

提交回复
热议问题