加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – web.config allowDefinition = MachineToApplication

发布时间:2020-12-16 04:17:55 所属栏目:asp.Net 来源:网络整理
导读:在根目录下,我有以下结构 ......web.configReport Folder- Login.aspx- Web.config | |- ViewReport | |- Report.aspx 在Report文件夹中的web.config文件中,我有以下内容: ?xml version="1.0"? configuration system.web authentication mode="Forms" forms
在根目录下,我有以下结构
..
..
..
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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读