⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adminlogin.aspx.cs

📁 一个网上书店的源码
💻 CS
字号:
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;
using MyBookShop.BLL;
using MyBookShop.Models;

public partial class Admin_AdminLogin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void imgbtnSure_Click(object sender, ImageClickEventArgs e)
    {
        User user;
        if (UserManager.AdminLogin(this.txtLoginId.Text, this.txtLoginPwd.Text, out user))
        {
            Session["AdminUser"] = user;
            #region 旧代码
            //FormsAuthenticationTicket tkt;
            //string cookiestr;
            //HttpCookie ck;
            //tkt = new FormsAuthenticationTicket(1, user.Name, DateTime.Now, DateTime.Now.AddMinutes(30), true, "your custom data"); //创建一个验证票据
            //cookiestr=FormsAuthentication.Encrypt(tkt);//并且加密票据
            //ck=new HttpCookie(FormsAuthentication.FormsCookieName,cookiestr);// 创建cookie
            //ck.Path=FormsAuthentication.FormsCookiePath;//cookie存放路径
            //Response.Cookies.Add(ck);
            #endregion
            string strRedirect;
            strRedirect = Request["ReturnUrl"];

            System.Web.Security.FormsAuthentication.SetAuthCookie(user.Name, true);
            if(strRedirect==null)
                Response.Redirect("~/Admin/ListAllUsers.aspx");
            Response.Redirect(strRedirect);
        }
        else
        {
            Response.Redirect("~/Error.aspx");
        }
        
    }

    protected void imgbtnCancel_Click(object sender, ImageClickEventArgs e)
    {
        this.txtLoginId.Text = String.Empty;
        this.txtLoginPwd.Text = String.Empty;
    }
}

⌨️ 快捷键说明

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