Monday, April 27, 2009

VS ASP.NET Error: it is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.

Error
Error while compiling solution in Visual Studio .NET: 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

Resolution
If there are any web.config files in the sub folders that make sure you don't duplicate the entries under of web.config in the root folder, in the web.config in the sub-folder.

For instance if the folder structure of your ASP.NET application is like this...
Login.aspx
Web.config
(In web.config
system.web
authentication mode="Windows"
system.web
)
Secure (folder)
Home.aspx
Web.config
(In subfolder web.config I Add the same I get error
system.web
authentication mode="Windows"
system.web
)
(In subfolder web.config I remove those entries, error goes off
system.web
!-- comment it
authentication mode="Windows"
system.web
)

No comments:

MSDN: U.S. Local Highlights