i see i can call Request.IsAuthenticated but how do i get the login name from asp.net membership provider once i am logged in?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s a number of mechanisms to get the currently logged on user’s name, for example, you can get to it via the context of the current web page like so:
However, usually the best way to get the current user’s name is via the context of the current Http request like so:
Ultimately, you’re calling down into the same “User” object, and accessing the same System.Security.Principal.IIdentity object instance in either case, but using the HttpContext allows this code to be used not only in web pages but also ASP.NET user controls and POCO classes etc.