Search code examples
asp.net-mvc-4windows-authentication

Authentication mode=windows not working


I am newbie to ASP.NET. I have an ASP.NET MVC 4 application from which I am trying to get the current loggedOn user using HttpContext. this is not running under IIS, but under FileSystem (as in running locally from Visual Studio 2012). I have set

<authentication mode="Windows"></authentication>

and still I do not get the loggedOn user.

Then I tried with:

<deny users="?"/>

Gives me access denied error, even though I have admin rights on my computer.

can somebody help in getting loggedOn userName through HttpContext?


Solution

  • found the solution in the settings of the project created. also found that, by default for a MVC 4->Single Page/Internet/Mobile Application the Anonymous Authentication will be enabled and Windows Authentication is Disabled. Changing the settings for Anonymous Authentication as Disabled and Enabling Windows Authentication did the trick.

    (seriously, this was dumb behavior at its best :'( )