共享Session

来源:互联网 发布:淘宝刷粉丝软件 编辑:程序博客网 时间:2024/05/01 08:45

asp.net转入asp 

trans.aspx

private void Page_Load(object sender, System.EventArgs e)
  {
   Session["name"] = "dfsdf";
   Session["sex"]="F";
   
   Response.Write("<form name=frm id=frm action=aspxtoasp.asp method=post>");
   foreach(object obj in Session.Contents)
   {
    Response.Write("<input type=hidden name='"+obj.ToString()+"'");
    Response.Write(" value = '"+Session[obj.ToString()].ToString()+"'>");
   }
   try
   {
    if(Request.QueryString["DestPage"].ToString().Length > 4 )
    {
     Response.Write("<input type=hidden name='DestPage'");
     Response.Write(" value = '"+Request.QueryString["DestPage"].ToString()+"'>");
    }
   }
   catch{}
   Response.Write("</form>");
   Response.Write("<scr"+"ipt language='javascript'>frm.submit();</scr"+"ipt>");
  }

aspxtoasp.asp      

<%for i=1 to Request.Form.Count Session(Request.Form.Key(i))=Request.Form(i) next if Len(Session("DestPage")) >4 then Response.Write(Session("DestPage")) end if call allsession() function allsession() Response.Write "There are " & Session.Contents.Count &" Session variables

" Dim strName, iLoop For Each strName in Session.Contents'使用For Each循环察看Session.Contents If IsArray(Session(strName)) then '如果Session变量是一个数组? '循环打印数组的每一个元素 For iLoop = LBound(Session(strName)) to UBound(Session(strName)) Response.Write strName & "(" & iLoop & ") - " & _ Session(strName)(iLoop) & "
" Next Else '其他情况,就简单打印变量的值 Response.Write strName & " - " & Session.Contents(strName) & "
" End If Next end function%>

把所有的Session都写入了asp session.

原创粉丝点击