📄 loginout.aspx.cs
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class loginout : System.Web.UI.Page
{
Class1 db = new Class1();
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserName"] == null || Session["UserName"].ToString() == "")
{
//Page.ClientScript.RegisterStartupScript(this.GetType(), "MessageBox", "alert('您还没有登录,请先登录')", true);
//加了下面这一句,弹不出警告对话框
// Response.Redirect("login.aspx");
Response.Write("<script>alert('您还没有登录,请先登录!');location.href='login.aspx';</script>");
}
else
{
Session["UserName"] = "";
Session["Role"] = "";
Session["UserID"] = "";
Session["Role"] = "";
//清空购物车记录
db.ExecSql("delete from ShopCart");
this.Page.Response.Redirect("favorite.aspx");
}
//Session.Abandon();//清空Session
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -