我们正在向应用程序添加几个不需要在登录后锁定的页面。我如何打开两个页面以供公众访问。
这是我的 Web.config:
<authentication mode="Forms">
<forms name=".ORGANIZATION" loginUrl="Default.aspx" protection="All" timeout="120"/>
</authentication>
<authorization>
<deny users="?"/>
<allow users="*"/>
</authorization>
我们希望 page1.aspx 和 page2.aspx 公开。我怎么会允许这样呢?
最佳答案
您可以在 web.config 中添加一个位置
来免除它们:
<configuration>
<!-- The rest of your web.config -->
<system.web>
<authentication mode="Forms">
<forms name=".ORGANIZATION" loginUrl="Default.aspx" protection="All" timeout="120"/>
</authentication>
<authorization>
<deny users="?"/>
<allow users="*"/>
</authorization>
</system.web>
<location path="page1.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="page2.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
</configuration>
关于web-config - 当其余页面需要授权时,允许公共(public)访问两个 ASP.NET WebForm 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8990940/