Form驗證

      <authentication mode="Forms" >
        <forms name=".name" protection="All" loginUrl="Login.aspx" defaultUrl="Default.aspx">         
        </forms>       
      </authentication>
      <!--這是用戶授權節-->
      <authorization >
        <deny users="?"></deny>
        <!--允許所有人登錄-->
        <!--<allow users="*"/>--><!--允許所有人登錄-->      

     </authorization>

頁面中:

添加命名空間:using System.Web.Security;

通過驗證:  FormsAuthentication.RedirectFromLoginPage("cookie中名字", false);

應用: Label1.Text = "歡迎"+User.Identity.Name+"來到保護頁"; //這時候:User.Identity.Name="cookie中名字“;

發佈了68 篇原創文章 · 獲贊 0 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章