通过在web.config中设置 <authentication mode="Forms">
<forms name="fei" loginUrl="Login.aspx" protection="All" timeout="30" />
</authentication>
<authorization>
<deny users ="?"/>
</authorization>阻止匿名用户访问页面.在页面中不能通过Response.redirct()来定位到某个页面,
但可以通过Server.transfer()来定位.这个是什么原因?
<forms name="fei" loginUrl="Login.aspx" protection="All" timeout="30" />
</authentication>
<authorization>
<deny users ="?"/>
</authorization>阻止匿名用户访问页面.在页面中不能通过Response.redirct()来定位到某个页面,
但可以通过Server.transfer()来定位.这个是什么原因?
把这个改下试试
而且好象你的forms 验证的目录没写?
<authorization>
<allow roles="VIP,System"/>
<deny users="*"/>
</authorization>
</system.web> allow 元素应该写在 deny元素之前
deny user="?" 中 "?" 表示拒绝匿名用户
而deny user="*" 表示拒绝全部用户
参考
http://www.cnblogs.com/wdfrog/archive/2008/08/19/1270864.html
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
<location path="A页面">
<system.web>
<authorization>
<allow roles="VIP,System"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
<location path="B页面">
<system.web>
<authorization>
<allow roles="VIP,System"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
</configuration>
这个说的很详细但我的问题是:在一个页面中,比如是A.aspx,有一个button,这个button链接B.aspx,在它的click事件中,
可以用Server.Transfer("B.aspx")到B.aspx,但不可以用Response.Redirect("B.aspx")达到这个要求
,这个是什么原因?
参考5楼
<authorization>
<allow roles="VIP,System"/>
<deny users="*"/>
</authorization>
</system.web> allow 元素应该写在 deny元素之前
deny user="?" 中 "?" 表示拒绝匿名用户
而deny user="*" 表示拒绝全部用户
参考
这确实是个问题
[code=MSDN]ASP.NET 不验证当前用户是否有权查看由 Transfer 方法提交的资源。虽然 ASP.NET 授权和身份验证逻辑运行于调用原始资源处理程序之前,但 ASP.NET 仍将直接调用 Transfer 方法指示的处理程序,并且不为新资源重新运行授权和身份验证逻辑。如果应用程序的安全策略要求客户端具有适当的授权才能访问相应的资源,则应用程序应强制再次授权或提供自定义访问控制机制。您可以使用 Redirect 方法而不是 Transfer 方法强制再次授权。Redirect 方法执行客户端重定向,此时浏览器请求新资源。此重定向是一个进入系统的新请求,因此,需要接受 Microsoft Internet 信息服务 (IIS) 和 ASP.NET 安全策略的所有身份验证和授权逻辑的检验。 您可以在应用程序调用 Transfer 方法之前,通过结合使用 IsInRole 方法的自定义授权方法来验证用户是否有权查看资源。[/code]