locked
Capturing the UserName works perfect on localhost, but fails when published to IIS RRS feed

  • Question

  • User1377981854 posted

    I have a web forms application using windows authentication. I need to show or hide some items on the form depending on who is logged in. I have tried using Environment.Username, HttpContext.Current.User.Identity.Name, and My.User.name – all work fine within Visual Studio on localhost but once I publish them to the server, it returns an empty string.

    I assume it is some setup-related issue on my server. Any ideas?

    Thursday, August 9, 2018 5:40 PM

All replies

  • User1724605321 posted

    Hi KeithHansen,

    One problem with getting the user name is that you have a dependency on the configuration in IIS.  Please refer to document :

    https://richhewlett.com/2011/02/15/getting-a-users-username-in-asp-net/ 

    And make sure you have correct configuration in IIS .

    Best Regards,

    Nan Yu

    Friday, August 10, 2018 3:31 AM
  • User-1320437544 posted

    Hello,

    If I was you I would check the application pool user account in IIS. Normaly it runs under limited system account. When you run in Visual Studio the integrated develompent server has more privilidges than deployment server and perhaps you are running your visual studio under administrative account in you dev. machine.

    Do some "diging" in this direction and let us know if it helped you.

    Cheers

    Wednesday, August 15, 2018 5:08 AM