zoukankan      html  css  js  c++  java
  • asp.net 中 Forms驗証

    web.config
        <authentication mode="Forms">
          <forms loginUrl="Login.aspx"
                 protection="All"
                 timeout="30"
                 name=".ASPXAUTH"
                 path="/"
                 requireSSL="false"
                 slidingExpiration="true"
                 defaultUrl="default.aspx"
                 cookieless="UseDeviceProfile"
                 enableCrossAppRedirects="false" />
        </authentication>

    所有用戶必須登陸
        <authorization>
          <deny users="?" />
        </authorization>
    允許所有用戶不需要登陸
    <allow users="*"/>

    指定用戶權限
    <allow users="Admin"/>
    <deny users="*"/>

    指定目錄裡面程序權限
    <location path ="Public">
                <system.web>
                    <authorization>
    <allow users="*"/>
    </authorization>
                </system.web>
           </location>

    <location path ="ManageSys">
                <system.web>
           <authorization>
    <allow users="Admin"/>
    <deny users="*"/>
    </authorization>
                </system.web>
           </location>

    指定某個具體化程序
    <location path ="ManageSys/Auditing.aspx">

    .cs程序中
     System.Web.Security.FormsAuthentication.RedirectFromLoginPage(this.TextBox1.Text, false);
    轉入到程序打開的頁面

    System.Web.Security.FormsAuthentication.SetAuthCookie(this.TextBox1.Text, false);
    Response.Redirect("Default.aspx");
    轉入到指定的頁面

    if (User.Identity.IsAuthenticated)
    {
                    Response.Write("已經登陸");
    }
    具體某個程序裡面判斷是否登陸

    System.Web.Security.FormsAuthentication.SignOut();
    登出

  • 相关阅读:
    设计模式:单一职责原则
    多线程的创建
    Android开发基础(java)14
    面向对象编程的思想(6)
    面向对象编程的思想(5)未完成
    面向对象编程的思想(4)
    面向对象编程的思想(3)
    面向对象编程的思想(2)
    面向对象编程的思想(1)
    GDB 命令详细解释
  • 原文地址:https://www.cnblogs.com/cnaspnet/p/532071.html
Copyright © 2011-2022 走看看