0

I'm trying the get the user's name [ex) admin, John, Lucy, etc.] so I can store it to a string and create a file path to save files in my application. I have absolutely no idea how to do this. I tried using the Microsoft.AspNet.Identity; namespace but that didn't help me any, as the UserManager class item is templated to take a User, which is what I'm trying to find in the first place. I'm honestly just walking through the forest at night right now. Can't see and no idea where to go. Any help would be awesome!! Thanks

Uchiha Itachi
  • 1,251
  • 1
  • 16
  • 42
  • Do you have the authentication for your application set up correctly in the web server? Assuming this is a web application because of your reference to `Microsoft.AspNet.Identity`. You should probably read up on how authentication works in ASP.NET: https://msdn.microsoft.com/en-us/library/eeyk640h.aspx – itsme86 Nov 09 '16 at 19:06
  • 1
    Do you mean http://stackoverflow.com/questions/1240373/how-do-i-get-the-current-username-in-net-using-c? – Clive Nov 09 '16 at 19:06

1 Answers1

1

Try this to get the username of the currently logged on user:

string username = Environment.UserName;

Microsoft Docs

This is in the system namespace, so there's no need to use Windows Identity.