【发布时间】:2012-07-26 17:23:32
【问题描述】:
我目前正在开发一个 ASP.NET 网站,该网站使用Forms Authentication 来限制对用户需要注册才能查看的某些文件 (~/resources/restricted/*) 的访问。不幸的是,这具有在网站的不相关部分中禁止背景 (~/common/images/backgrounds/bg_community.jpg) 的额外效果。
我的配置有什么问题/我该如何解决?
~/Web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<!-- ... --->
<system.web>
<!-- ... --->
<authentication mode="Forms">
<forms loginUrl="~/users/login.aspx" />
</authentication>
<!-- ... --->
</system.web>
<!-- ... --->
<location path="~/resources/restricted">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
<!-- ... --->
</configuration>
【问题讨论】:
-
你不能用
为公共图像目录添加另一个“位置”部分吗? (但也许你已经尝试过了。) -
好吧,我真的不想为每个目录都这样做。我正在寻找一种仅排除
~/resources/restricted目录并保留其余部分的解决方案。
标签: asp.net web-config forms-authentication