admin.aspx.cs

来自「.net的一个很经典很普通的实例」· CS 代码 · 共 41 行

CS
41
字号
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class admin_admin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //从cookie中获取身份验证票信息
        string cookieName = FormsAuthentication.FormsCookieName;
        HttpCookie authCookie = Context.Request.Cookies[cookieName];
        if (authCookie != null)
        {
           
            //解密
            FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
           Label1.Text  = "欢迎您:"+authTicket.Name.ToString();
            Label2.Text= "角色:"+authTicket.UserData.ToString();

        }
        Link1.Attributes.Add("onmouseover","select1();");
        Link2.Attributes.Add("onmouseover", "select2();");
        Link3.Attributes.Add("onmouseover", "select4();");
        Link4.Attributes.Add("onmouseover", "select3();");
     
     
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        System.Web.Security.FormsAuthentication.SignOut();
        Response.Redirect("/MovieShow/Default.aspx");
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?