zoukankan      html  css  js  c++  java
  • 为不同目录设置Forms身份验证

     在进行Forms身份验证时,如果采用如下的方法配置web.config的话,则会出现所有的页面都要进行验证,这是用户所不能容忍的,具体代码如下:
    这里我还要说明一点,很多初学者都会把上面的代码写为
    1<authentication mode="Forms" />   
    2    <forms name=".LoginUser" loginUrl="admin/admin_login.aspx" protection="All" timeout="30" />   
    3  </authentication>
    4    <authorization>               
    5        <allow users="*" />
    6
    结果会出现不能识别forms节点。
    如果要实现某个目录下的Forms验证哪个怎么办呢?
    其实代码很简单,在添加完上面的代码之后再在</system.web>后要加入:
    1 <location path="admin">
    2    <system.web>
    3<authorization>
    4<deny users="?" />
    5<allow users="*" />
    6</authorization>
    7    </system.web>
    8</location>
    9
    便可以实现对admin这个目录进行验证,而其它的则不需要进行验证就可以直接访问。


  • 相关阅读:
    88. Merge Sorted Array
    87. Scramble String
    86. Partition List
    85. Maximal Rectangle
    84. Largest Rectangle in Histogram
    83. Remove Duplicates from Sorted List
    82. Remove Duplicates from Sorted List II
    81. Search in Rotated Sorted Array II
    80. Remove Duplicates from Sorted Array II
    计算几何——点线关系(叉积)poj2318
  • 原文地址:https://www.cnblogs.com/zhangchenliang/p/673451.html
Copyright © 2011-2022 走看看