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

后端 未结 7 845
清歌不尽
清歌不尽 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 06:11

    As already suggested FormsAuthentication.RedirectFromLoginPage() method, sets the Authentication Cookie automatically.

    However in my case, i had nested web applications where i had cleared tag in child application (so that it does not inherit httpModules from its parent application) in the web.config file. Removing the unwanted parent httpModules made everything work again.

    its better to check this tag before complicating things :)

提交回复
热议问题