c# - Get current user's name and user id -


I will not do ASPX trying to accomplish this simple task.

I see the following code in some CS files that seems to be the current user and I think this is a standard method in an asp but may be incorrect: < p> CS:

  user user = (user) Context.Items ["CurrentUser"];   

I have tried this kind of thing from other posts here, but maybe the system is different or setup is different? Then I do not know.

  var currentUser = Membership GETUser (User.Identity.Name); String usernames = currentUser.UserName; // ** username grid user id = current user Provider user; // ** Get User ID   

Do anyone know how to get the current user's name and user ID on the basis of above?

It depends on how you handle users in your website.

If you use ASP.NET built in user management, then User.Identity.Name will get you the currently logged in user name.

Other stuff like (user) references. The item ["current user"] or (user) session ["myUser"] will be available to the user who was saved somewhere in your website.

Click on the page you want to start your way through to login, and follow the function to see how users are controlling your website.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -