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

标签 asp.net web-config

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

..
..
..
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

关于asp.net - web.config allowDefinition = MachineToApplication错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16307112/

相关文章:

c# - sql查询和下拉列表

c# - 奇怪的 'MySqlSiteMapProvider' 错误虽然正在使用 'XmlSiteMapProvider'

c# - 无法转换类型为 'System.Data.Objects.MaterializedDataRecord' 的对象

c# - 从数据库中获取数据并使用 View 模型将其传递给 View

c# - 为什么我不能在三元 if 语句中将可为 null 的 int 设置为 null?

c# - 位置0处无行错误处理

asp.net - 如何在 Web.config 中为 SmtpClient 启用 SSL

web-config - 如何让 TFS 2010 Builds 使用新的构建配置并转换 web 配置

将特定页面重定向到 iis web.config 中的另一个特定页面

asp.net-mvc-3 - 无法为 mvc3 .net Web 应用程序设置 <customErrors mode ="off">