28,391
社区成员
发帖
与我相关
我的任务
分享
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<%
''----------测试数据--------
session("name")="srx"
session("id")="1"
session("sex")="f"
session("pass")="asdfas"
session("age")="23"
session("weight")="131"
''--------------------------
Response.Write("<form name=frm id=frm action=""asptoaspx.aspx"" method=post >")
for each Item in Session.Contents
Response.Write("<input type=hidden name="&Item& " value="&session(item)&">")
Next
if len(Request.QueryString("Destpage")) >4 Then
Response.Write("<input type=hidden name=DestPage value=" & Request.querystring("DestPage") & ">")
end If
Response.Write("</FORM>")
Response.Write("<scr" + "ipt>frm.submit();</scr" + "ipt>")
%>
<body>
</body>
</html>
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;
namespace WebApplication1
{
public partial class asptoaspx : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Session.Timeout = 60;
for(int i=0;i<Request.Form.Count;i++)
{
Session[Request.Form.GetKey(i)]=Request.Form[i].ToString();
}
allsession(); //输出所有的Session,使用时可注释掉
try
{
if( Session["DestPage"].ToString().Length >4 )
{
Server.Transfer(Session["DestPage"].ToString(),true);
}
}
catch {}
}
private void allsession()
{
Response.Write ("There are " + Session.Contents.Count +" Session <I>var</I>iables<P>");
foreach(object obj in Session.Contents)
{
Response.Write("Session["+obj.ToString()+"] - "+Session[obj.ToString()].ToString()+"<br>");//输出所有的Session,使用时可注释掉
}
}
}
}