<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ses.aspx.cs" Inherits="ses5.ses" %>
<%--IE8 support JSON--%>
Session Test
Ctrl KC, KU, KD; build: Ctrl+Shift+B;
form 1
Form 2
Form 3
Form 4
Form 5: password --> session
<%--do not remove the code below--%>
Rpt2 =================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ses5
{
public partial class rpt2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if ((Session["username"] != null) && (Session["username"].ToString().Length > 1))
{
//do nothing
txMsg.Text = Session["username"].ToString();
// base.OnLoad(e);
}
else
{
// not login then redirect to login page
Response.Redirect("~/login.aspx");
}
}
protected void btnKillSes_Click(object sender, EventArgs e)
{
Session.Remove("username");
Session["username"] = null;
Session.Abandon(); // Does nothing
Session.Clear(); // Removes the data contained in the session
Response.Redirect("~/login2.aspx");
}
}
}
============================Rpt1.aspx=======
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ses5
{
public partial class rpt1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string user = Request.QueryString["user"];
if (user != null)
{
this.txUser.Text = user;
// create session and then redirect page
Session["username"] = user;
Response.Redirect("~/rpt2.aspx");
base.OnLoad(e);
}
else
{
this.txUser.Text = "user not found in session";
}
}
}
}
============ Ses51.asp ==============
ASP Session Test
<%
Response.Write(Session.SessionID)
%>
No comments:
Post a Comment