<authentication mode="Forms">
<forms name="forums" path="/" loginUrl="Login.aspx" protection="All" timeout="40"></forms>
</authentication>
这我很疑惑? 怎么改呀?
错误是: 在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的节是错误的。如果在 IIS 中没有将虚拟目录配置为应用程序,则可能导致此错误。
怎么改?
怎么办?
急求答案!!!谢谢
<forms name="forums" path="/" loginUrl="Login.aspx" protection="All" timeout="40"></forms>
</authentication>
这我很疑惑? 怎么改呀?
错误是: 在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的节是错误的。如果在 IIS 中没有将虚拟目录配置为应用程序,则可能导致此错误。
怎么改?
怎么办?
急求答案!!!谢谢
<authentication mode="Forms"> 是应用级别的,不能在子目录级别的web.config内
设置,把它放在应用级别的web.config里,在子目录下用 <authorization>节来控制访问。
即: <system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web> 根目录下的web.config: <authentication mode="Forms">
<forms loginUrl="~/admin/login.aspx" name="login" />
</authentication>
<authorization> <allow users="*" />
</authorization>
这里可能还有其他问题引发的
在ASP.NET2.0中,如果根目录允许匿名用户访问,而根目录下的一个页面(如Index.aspx)必须要登录(假设登录页面为login.aspx)后才能访问,根目录下的web.config文件必须这样配置:<?xml version="1.0"?><configuration>
<appSettings>
</appSettings>
<connectionStrings>
</connectionStrings><system.web>
<compilation debug="true"/><!--<authentication mode="Windows"/>-->
<authentication mode="Forms">
<forms loginUrl="login.aspx" protection="All" path="/" timeout="30"/>
</authentication><authorization><!--允许匿名-->
<allow users="?"/></authorization></system.web>
<location path="Info.aspx">
<system.web><!--认证项配置(在为一个单独页面指定认证信息时,authentication节只能从这个目录继承,不能单独设置)-->
<!--
<authentication mode="Forms">
<forms name=".www.cnpp.info" loginUrl="login.aspx" protection="All" path="/" timeout="30"/>
</authentication>
--><!--用户访问控制-->
<authorization><!--阻止匿名-->
<deny users="?"/></authorization>
</system.web>
</location>
</configuration> 也就是在需要认证的页面配置节中不能配置authentication项,只能在在根目录中配置authentication项,Info.aspx从根目录继承. 否则会出现这样的错误: "在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的节是错误的。如果在 IIS 中没有将虚拟目录配置为应用程序,则可能导致此错误 "
"应用程序设置"这里,点一下创建
选择网站属性设置相应框架
<system.web>
<authentication mode="Forms">
<forms loginUrl="login.aspx">
</forms>
</authentication>
<authorization>
<allow users="?" />
</authorization>