Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'd like to play about with WindowsAuthentication but am seemingly falling down at the first hurdle.

So I created an empty ASP.Net Webforms app and amended the web.config as so:

<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0"/>
        <httpRuntime/>

        <authentication mode="Windows" />
        <identity impersonate="true"/>
    </system.web>
</configuration>

Fire up the app and on page load check the following for a value:

HttpContext.Current.User.Identity.Name

but it returns an empty string (and also shows that HttpContext.Current.User.Identity.IsAuthenticated is false).

My expectation was to see my windows account name returned e.g. mydomain\rob

Where am I going wrong?

share|improve this question
    
Using IIS or ASP.NET Development Server? –  sq33G Jun 13 '13 at 10:09
    
I was using IIS Express (from VS). Switched to using ASP.Net Dev Server and it works as I expected... –  glosrob Jun 13 '13 at 10:20

1 Answer 1

up vote 1 down vote accepted

In IIS, Windows Authentication won't work while Anonymous Authentication is enabled.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.