allowDefinition=’MachineToApplication’

It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level

Scott Michell wrote an excellent article about the above error explaining exactly why are you getting this error. Basically you are opening the parent folder of a project in Visual Studio and you get this error. Since web.config in this case is in sub folder, you get this error.

A little Explanation

There can be more than one web.conf files in your application. They can be all in root or in sub folders as in nested form. The root web.conf can contain almost all elements but that that are nested in sub folders may not contain certain elements. This error is about this scenario.

Resolution

Lets say you have project in this folder

d:\project\myfirstapp\main\

If you open myfirstapp in Visual Studio you will get the above error. To resolve reopen the project and select main as your project.