<%@ 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 {
return false;
}
}}//↑↑↑此窗体只是想显示一下刚才存的session 但是值一直是null!!!小弟跪求原因!望大神解答!谢谢!!!Session 传值 null
<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 {
return false;
}
}}//↑↑↑此窗体只是想显示一下刚才存的session 但是值一直是null!!!小弟跪求原因!望大神解答!谢谢!!!Session 传值 null
解决方案 »
- 还是两个dropdownlist和一个button…
- 【在线结贴】求一SQL语句。根据子节点ID获得父节点ID。
- MSDN EXPRESS 是什么东东
- 程序要连接数据库是不是一定要配置app.config或者web.config?
- 动态刷新的小问题?
- 菜鸟刚学asp.net,想把2个数据表里的数据加到treeview控件中,具体怎么写呢??
- 请大侠们帮忙出出主意
- 一个int的值如 123456789 我想把它ToString()显示成123,456,789该怎么做?
- 怎样在TreeView中的SelectedIndexChanged事件中获取当前结点和父结点的文本??
- 我的论文,大家帮忙
- 微软企业库 未能加载文件或者程序集
- @Html.CheckBoxFor(a => a.AtlAdd, null)
{
context.Session["aaa"] = a;
context.Response.Redirect("S3.ashx");
}
a为null不?给Session赋值的语句有没有执行?还有,你继承的是IReadOnlySessionState,这个从名字上看就是只读的吧。。,