I've noticed a strange issue when FTP publishing my ASP.NET MVC app in Visual Studio:
After publishing, it won't compile. I get this error:
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.
From my research so far, this error generally occurs when a Web.config file containing certain sections is deeper than root in the project's folder hierarchy.
Well, it turns out I do have some Web.config files deeper in the hierarchy, which I found in these folders:
- [project folder]\obj\Release\Package\PackageTmp
- [project folder]\obj\Release\TransformWebConfig\original
- [project folder]\obj\Release\TransformWebConfig\transformed
The problem is, I didn't put these files in these locations. They get copied there during the publish process (specifically, FTP publish). If I manually delete the Web.configs (or rebuild my solution), I'm once again able to compile. (Well, rebuild usually works--it will fail if I switch from Debug to Release or vice versa after publishing.)
Now, to my questions:
Have I messed up a setting or done something wrong or is this basically just a nuisance that I have to deal with? Should I be concerned? Is this problem fixable?