zoukankan      html  css  js  c++  java
  • 配置 authorization deny allow

    http://blog.csdn.net/wwlearn/article/details/5457310

    <authorization>
        <deny users = "?"/>
        <allow users= "*" />
    </authorization>

     

    ?:匿名用户,也就是没有登入的用户不能访问。
    *:所有用户,所有用户都不能访问。

     

    <deny users = "?"/>、 是拒绝匿名用户访问
    <allow users= "*" /> 允许所有的用户访问包括匿名用户

     

    <authentication mode="Forms">
         <forms name=".ASPXAUTH" loginUrl="~/login.aspx"></forms>
           <!-- 默认cookie 名 及登陆页面地址  -->
       </authentication>
       <authorization>
         <deny users="?"></deny> <!-- 禁止匿名访问  -->
       </authorization>

     

    <location path="Default.aspx"><!--允许所有人访问这个页面-->
        <system.web>
          <authorization>
            <allow users="*"/>
          </authorization>
        </system.web>
      </location>

    // 自定义票据,获取用户的roles,写到票据中。票据会携带在cookie中。
               FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
                   1,                                         // version
                   loginID,                               // user name
                   DateTime.Now,                              // creation
                   DateTime.Now.AddMinutes(60 * 20),               // Expiration
                   false,                                     // Persistent
                   "");                              // userData

               String encryptedTicket = FormsAuthentication.Encrypt(authTicket);
               HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
               Response.Cookies.Add(authCookie);
  • 相关阅读:
    junit单元测试:@Before、@After
    package打包报错:There are test failures
    报错:程序包com.sun.image.codec.jpeg不存在
    报错:Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
    elementui表格table组件的树形表格
    Linux常用命令
    黑马程序员hibernate2017版4天的讲义免费下载
    腾讯云服务器如何开放端口?
    文本编辑器中使用正则表达式进行替换的示例
    Lambda表达式
  • 原文地址:https://www.cnblogs.com/shiningrise/p/2951784.html
Copyright © 2011-2022 走看看