Search code examples
asp.netweb-configwindows-authentication

Why am I getting this err when I only have one Web.config file?


I am getting this err msg when I try to Rebuild a website:

It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

It refers to this line in Web.config:

<authentication mode="Windows"/>

According to the accepted and highly upvoted answer here, this problem occurs when there are multiple Web.config files, but my website has just this one.

If I simply comment out the offen[ding,sive] line, I get the same err msg when trying to rebuild, but on another line in the Web.config file, namely this one:

<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="60"/>

And so I think this will be a "whack-a-mole" if I keep it up, and eventually the effect of commenting out things will have some other malevolency, and thus this is untenable. What can I do to rectify this?

BTW, I did convert the site to an app in IIS.


Solution

  • Yes, I saw that Filburt was bloodhounding the problem after I figured it out. I had to go to IIS, select the folder beneath the site, and then right-click that and select "Convert to Application" - then the build error went away.

    I had previously done that just for the site itself, but not for the folder beneath it. So if doing it for the site has no effect, why is it afforded?

    To be plain to future sufferers/questers after a solution to this irritating conundrum, here is a screenshot of the site in question, in IIS 7.5:

    enter image description here

    So, "Converting to Application" of EMS did nothing; but "Converting to Application" of "customerreportingnet" did.