【发布时间】:2009-09-24 12:39:45
【问题描述】:
我有一个数据驱动的 asp.net mvc 应用程序。页面的 Url 也是数据驱动的,因此它们不能在 web.config 中硬编码。 我们已准备好部署网站,最初几天,我们希望页面只有在登录后才能访问。
是否可以向站点添加授权,然后仅通过更改 web.config 将其取出? 我已经添加了这个:
<authentication mode="Forms">
<forms loginUrl="Login.aspx" timeout="20">
<credentials passwordFormat="Clear">
<user name="admin" password="adminpwd" />
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
但是,这不起作用。
我也尝试过位置标签,但不确定在其中指定什么路径。
<location>
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
请注意:默认错误页面无需授权即可工作
<customErrors mode="Off" defaultRedirect="/error">
</customErrors>
你能帮忙吗?
谢谢!
【问题讨论】: