This error can be caused by a virtual directory not being configured as an application in IIS.
This error is caused mainly for two reasons.
1. Virtual directory not configured in IIS.
If you have not Configured your application to run on IIS then Create a virtual directory and assign permissions to Application (Read,Write).
Open IIS manager by typing INETMGR by clicking start menu > Run on windows
This will open IIS manager, now right click on the folder containing ur web application files and select properties.
In directory tab click on create button associated with Application name section.
Click on apply and this should fix the problem.
2. Two or more web.config files.
Chekc whether u r having two or more web.config files in ur application ?
If yes than remove one, web.config file should be in root under virtual directory.
Remove any backup folders if you have which may contain web.config file.
Hope this helps