日期:2014-05-17  浏览次数:20423 次

小弟菜鸟,跪求关于Session的问题!
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="S2.aspx.cs" Inherits="S2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" action="S4.ashx" runat="server">
    <div>
  

    <input type="text" name="LoginId" /><br />
    <input type=text name="LoginPwd" /><br />
    <input type="submit" value="login" />
    </div>
    </form>
</body>
</html>

//↑↑↑上边是第一个web窗体
//第一个窗体的form把值传给下面的ashx     ↓↓↓
<%@ WebHandler Language="C#" Class="S4" %>

using System;
using System.Web;
using System.Web.SessionState;

public class S4 : IHttpHandler,IReadOnlySessionState {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/html";
        string a=context.Request.Form["LoginId"].Trim();
        if (a != null)
        {
            context.Session["aaa"] = a;
            context.Response.Redirect("S3.ashx");
        }
        else
        {

            context.Response.Write("出错了");
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}
//如果检测到有用户名输入的话 则写入一个Session 然后页面跳转到下一个窗体   ↓↓↓
<%@ WebHandler Language="C#" Class="S3" %>

using System;
using System.Web;
using System.Web.SessionState;

public class S3 : IHttpHandler,IReadOnlySessionState {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/html";
        string a =Convert.ToString( context.Session["aaa"]);
        context.Response.Write(a);
    }
 
    public bool IsReusable {
        get {