在根目录下,我具有以下结构
..
..
..
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/