Results 1 to 5 of 5

Thread: [RESOLVED] System.Environment.UserName returns ASPNET

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2006
    Location
    CA, USA
    Posts
    81

    Resolved [RESOLVED] System.Environment.UserName returns ASPNET

    Hi,

    I am using

    Response.Write(System.Environment.UserName);

    in ASP.NET2.0 C#. When I run this from my VS2005 it returns my windows login ID. When I deploy the application it returns me ASPNET. Do I need to change any settings to display the client's Windows ID? very urgent please

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,173

    Re: System.Environment.UserName returns ASPNET

    You will need to change the security settings for your web application or virtual directory in deployment. Go to IIS, properties for that website, security, and check the "Windows Authentication" box.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,173

    Re: System.Environment.UserName returns ASPNET

    The reason it worked in development mode is because Visual Studio gets the web application to run under the security context of the logged in user in Windows by setting this windows authentication checkbox checked automatically when the application is created in IIS.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Apr 2006
    Location
    CA, USA
    Posts
    81

    Re: System.Environment.UserName returns ASPNET [Resolved]

    Thanks Mendhak... It is working fine

    I included these 2 lines in web.config

    <identity impersonate="true" />
    <authentication mode="windows" />

    I saw these lines in some forums. I did not try if my code will work without hese lines or not. I ll do that test later.

    and then in IIS in security unchecked "Anonymous access" and checked "Integrated Windows Authentication"

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,173

    Re: [RESOLVED] System.Environment.UserName returns ASPNET

    Setting identity impersonate to true will make the application run under the security context of the logged in user rather than the ASP.NET worker process. This is a commonly used scenario in many intranet applications (but obviously not internet)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width