Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
when i run this code to get user name of windows it run OK in localhost but when i run with ip it running with out error but the user name not showing
C#
System.Security.Principal.IPrincipal user;
            user = System.Web.HttpContext.Current.User;
            System.Security.Principal.IIdentity identity;
            identity = user.Identity;
            TextBox1.Text = identity.Name.Substring(identity.Name.IndexOf(@"\") + 1);
Posted
Comments
Prasad Khandekar 21-May-14 11:00am    
Are you user the user is authenticated? Please have a look at this thread (http://stackoverflow.com/questions/1056487/httpcontext-current-user-identity-name-is-always-string-empty).

Regards,
ZurdoDev 21-May-14 16:46pm    
IP of localhost or IP of a different server?
mohd598 22-May-14 6:53am    
yes IP for local host

1 solution

Hello friend, please check Integrated Windows authentication option and uncheck Enable anonymous access option in Authentication Methods window IIS.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900