How to get current user's name?

Hi, I'm using vs2012, C# and asp.net.
why I'm getting"" with this User.Identity.Name; in my code in my C# program. I was hoping to be able to get user id/name of their window's login.  How can I get a user's name/credential whey they are visiting my web page?

Thank you.
lapuccaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Ammar GaffarConnect With a Mentor Software EngineerCommented:
How you are expecting to have user identity information without authentication?

Unless you setup your IIS to use Windows Authentication and configure your asp.net application to use Windows Authentication mode and login using your windows credentials you will not be able to read user identity information.
0
 
Dave BaldwinFixer of ProblemsCommented:
You can only do that if you have a 'login' for your pages.  Normal visitors that do not have to login do not leave any personal info that you can get.
0
 
Ammar GaffarSoftware EngineerCommented:
If your asp.net is internet based (Hosted in Internet and visitors don't have to login to access it) then you can't, but if your asp.net application is intranet based (Hosted inside your company and using your company AD - Windows Authentication) then you can.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
lapuccaAuthor Commented:
This will be an Intranet.  I'm still developing it and is running from my VS2012 on my PC.  Why am I just getting ""?  How can I get my id /name to display?  I am logon to our company network VPN using Cisco Anyconnect right now.  
Thank you.
0
 
David Johnson, CD, MVPConnect With a Mentor OwnerCommented:
in your authorization and authentication in IIS are you using windows authenticaton
0
 
lapuccaAuthor Commented:
I will set it up in IIS to use Windows authentication.  However, I'm still developing the program and right now it's just running on my local PC from VS2012.  But still, shouldn't it display the name?
0
 
lapuccaAuthor Commented:
Okay, that makes sense.  I'll see if that works when I set it up in our IIS server.    Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.