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.
Cause
One encounters this error while running a WebSite project. This error is encountered when one selects the parent folder of a website project instead of the Website itself in the Website Browser.
The reason is for a project to ASP.Net run it needs Web.Config which is inside the Website folder and not its parent and since you selected parent folder it throws the above error.
As you can see in the figure below I am selecting the parent folder of the Website and not my website
And when I try to run it I get the above error. Refer figure below.
Solution
There are two solutions
1. Cut and paste the Web.Config in the from the WebSite folder to the parent folder
2. Recommended Solution: Select the Website itself rather than its parent folder in the WebSite Browser.
In the figure below, I am now selecting WebSite itself and not its parent
A thumb rule to avoid this error check if your Website’s Root folder has Web.Config or Not