get logged in user name
-
I want to display the name of the user that is currently logged on in the system. PS:- Using VS-2013, ASP.NET and I am freshers so please be specific Don't have much idea about authorization, identity or authentication. Thank You
-
I want to display the name of the user that is currently logged on in the system. PS:- Using VS-2013, ASP.NET and I am freshers so please be specific Don't have much idea about authorization, identity or authentication. Thank You
Then the better thing would be to first go and learn ASP.NET's authentication modules, or the framework being used. You might be using Identity; or a
WebSecurity
-based method of authentication which can be answered by the way you create your application -- as a new project or a new website. If that is theWebSecurity
[^]-based application (a website), then you can do that like this,var username = WebSecurity.CurrentUserName; // the email field in database
Or you can get the UserId of the user and query the database to get the Name. Otherwise, if you're using Identity[^], then you would have to query the database anyway; Entity Framework has got you covered! You can get the values from the database as,
// db is the DbContent variable, and someUserId can be the current user's id.
db.Users.FirstOrDefault(x => x.Id == someUserId);
You can then move on and learn other basics about ASP.NET from MSDN, or the best option. Test, try and solve method!
The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~