asp.net – web.config allowDefinition = MachineToApplication错误

在根目录下,我有以下结构
..
..
..
web.config
Report Folder
- Login.aspx
- Web.config
  |
  |-> ViewReport
       |       
       |-> Report.aspx

在Report文件夹中的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>

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

在应用程序级别之外使用注册为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>

解决方法

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

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

Error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....