我在web.config里申明了验证模式如下:
<authentication mode="Forms"> 
<forms name=".ASPXCOOKIE" loginUrl="index.aspx" protection="All" timeout="30" />
</authentication>IIS也设置成匿名可访问了,但当前第一次打开不是index.aspx的时候,它并不跳转,真郁闷,是不是在代码里还要做判断?  应该不要吧?

解决方案 »

  1.   

    跳转什么?你都匿名访问了:)。要实现跳转两个可选的方法:
    方法1:
    <authentication mode="Forms"> 
    <forms name=".ASPXCOOKIE" loginUrl="index.aspx" protection="All" timeout="30" />
             <!-- 这里设置不允许匿名访问的路径 -->
    </authentication>方法2:在需要验证的页面装载的时候,判断用户是否通过验证,如果没有,使用Response.Redirect方法跳转。
      

  2.   

    我的博客有詳解http://blog.csdn.net/cityhunter172
      

  3.   

    我猜想樓主是忘記設置以下節點了<authorization><deny users="?"></deny></authorization>我的博客有詳解http://blog.csdn.net/cityhunter172
      

  4.   

    补充:在方法2中,你也可以使用FormsAuthentication.RedirectFromLoginPage 
    方法跳转。