Search code examples
c#asp.netiisweb-configwindows-authentication

How can I set windows authenication from web.config properly


I'm confused about how to set windows auth. in asp.net 4.5 should I do it from IIS only without setting any configuration in web.config or should I do it from web.config without setting anything in IIS

I am using asp.net forms 4.5 on windows 8.1 and IIS 8.5.

sub-issue: when I set it from iis it works fine by disabling anonymous auth. and enabling windows auth. but when I try to do it a lone from web.config it won't work. I do it like that

<authentication mode="Windows" />
<authorization>      
    <deny users="?" />
</authorization>

and I leave the default configuration in IIS what is happing is I keep getting Access is denied I was expecting to have my local account logged-In but i just got access is denied

I am not in a domain


Solution

  • I misunderstood the nature of the relationship between IIS and ASP.NET

    I read about it and I found it should be set from both and it depends on what authentication I am going to use

    for example If I am using windows authentication I have to set it first from IIS and after that from web.config, simply because IIS will authenticate the request first and pass authentication token to asp.net authentication module which should be set in the web.config