web.config allowDefinition = MachineToApplication错误

Nat*_*Pet 7 asp.net web-config

在根目录下,我有以下结构

..
..
..
web.config
Report Folder
- Login.aspx
- Web.config
  |
  |-> ViewReport
       |       
       |-> Report.aspx
Run Code Online (Sandbox Code Playgroud)

在我的报告文件夹中的web.config文件中,我有以下内容:

    <?xml version="1.0"?>
    <configuration>
        <system.web>
            <authentication mode="Forms">
                <forms loginUrl="Login.aspx" defaultUrl="ViewReport/Report.aspx">
                    <credentials passwordFormat="Clear">
                        <user name="Johl" password="pass888"/>
                    </credentials>
                </forms>
             </authentication>
         </system.web>

        <location path="ViewReport/Report.aspx">
            <system.web>
                <authorization>
                    <allow users="Johl"/>
                    <deny users="*"/>
                </authorization>
            </system.web>
         </location>
     </configuration>
Run Code Online (Sandbox Code Playgroud)

当我开始调试时,我收到以下消息:

在应用程序级别之外使用注册为allowDefinition ='MachineToApplication'的部分是错误的.此错误可能是由于未在IIS中将虚拟目录配置为应用程序引起的.

请注意,在我的根web.config中,我有以下内容:

在我的根目录中,我已经拥有以下内容:

         <system.web>        
            <authentication mode="Forms">
                <forms loginUrl="Str/StrUserLogin.aspx" timeout="2880" slidingExpiration="true"  />         
               </authentication>
            <authorization>
                <allow users="*" />
            </authorization>     
         </system.web>
Run Code Online (Sandbox Code Playgroud)

Iri*_*ain 10

在站点根目录创建虚拟目录.这可以通过Web选项卡下的VS中的项目属性来完成.

您也可能在子目录中定义了应该位于根配置文件中的内容.看到类似的问题:

在应用程序级别之外使用注册为allowDefinition ='MachineToApplication'的部分时出错


Syn*_*ror 5

将文件夹/项目转换为IIS中的应用程序可以解决此错误.