Configuration Error Description:An error occurred during the processing of a configuration file required toservice this request. Please review the specific error details below and modifyyour configuration file appropriately.
Parser Error Message: Itis an error to use a section registered asallowDefinition='MachineToApplication' beyond application level. This error canbe caused by a virtual directory not being configured as an application inIIS.
解决方法:
情况1:When you create an new webapplication using visual studio.net, it automatically creates thevirtual directory and configures it as an application.
However, ifyou manually create the virtual directory and it is not configured asan application, then you will not be able to browse the application and
may get the above error. The debug information you get as mentioned above, is applicable to this scenario.
Toresolve it, Right Click on the virtual directory - select propertiesand then click on "Create" next to the "Application" Label and thetextbox. It will
automatically create the "application" using the virtual directory's name. Now the application can be accessed.
情况2:When you havesub-directories in your application, you can have web.config file forthe sub-directory. However, there are certain properties which cannot
beset in the web.config of the sub-directory such as authentication,session state (you may see that the error message shows the line numberwhere the
authentication or sessionstate is declared in theweb.config of the sub-directory). The reason is, these settings cannotbe overridden at the sub-directory level
unless the sub-directory is also configured as an application (as mentioned in the above point).
Mostlywe have the practice of adding web.config in the sub-directory if wewant to protect access to the sub-directory files (say, the directoryis admin and we
wish to protect the admin pages from unathorized users).
Butactually, this can be achieved in the web.config at the application'sroot level itself, by specifing the location path tags andauthorization, as follows:-
However,if you wish to have a web.config at the sub-directory level and protectthe sub-directory, you can just specify the Authorization mode asfollows:-
Thus you can protect the sub-directory from unauthorized access.
当你把web.config放在网站程序中的子文件夹时,有一些属性不能设置,如authentication, session state
(错误信息显示子文件夹中web.config声明的authentication, session state 所在的行号)。
原因是这些设置不能被子文件夹的权限覆盖(override),除非子文件夹本身被设置成网站程序。
通常情况下我们希望把web.config放在子文件夹中来保护对子文件夹中文件的访问
(假设目录是admin,我们希望保护admin里面的文件不被未授权的用户访问)