• I need the webpage to retrieve the windows username (using My.User.Name). It works fine on my local machine, only when i test it on the local webserver it doesn't return anything. I would appreciate somebody's help on this topic. Thanks!

    Tuesday, September 04, 2007 7:51 AM


  • Hi,


    My.User.Name property relies on the current IPrinciple object's Identity to get the user name. In other words, this is the equivalent of My.User.Name

    • In Web Site: My.User.Name = HttpContext.Current.User.Identity.Name.
    • In Web Application: My.User.Name = System.Threading.Thread.CurrentPrinciple.Identity.Name.

    When debugging on local machine, the user identity is your user account, which contains user name information. When the web site is accessed from a local web server, the user identity will depend on IIS settings. In the default case of anonymous access for IIS, this user identity does not have a name, so it doesn't return anything.


    My experience with user authentication in ASP.NET is pretty limitted so I can only suggest some useful links relating to this topic. The forums on are good places to find the experts for your questions.

    Best regards,

    Wednesday, September 05, 2007 6:03 PM