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();
    登出

  • 相关阅读:
    arcpy脚本使用多接图表图斑对对应多幅影像进行裁边处理
    小辉轶事
    一些常ArcGIS常用简单算法 C#
    Wowza 4.5 修改 manager 端口号
    win7x64 串口程序无法运行,提示:component 'MSCOMM32.OCX' or one of its dependencies not correctlu registered。。。
    win7不正常开关机,系统恢复选项
    远程桌面+程序自启动
    Beyond Compare4 激活
    edusoho 支持同一账号多人同时登录
    windows 2008 gpt
  • 原文地址:https://www.cnblogs.com/cnaspnet/p/532071.html
Copyright © 2011-2022 走看看