Asp sharing session with asp.net

  This is an old topic, because the last to use, so there is no way to find information.    Microsoft's Web site provides a database used to achieve, and总觉too troublesome, but also said that the use of direct, but I did not test proved successful.    I think that the direct use is impossible.    There is another way to do this is through several pages conversion, I am using this method is, by summing up the information search, after finishing the preparation of a few pages to convert.    Mainly through the hidden input to achieve.    Specific methods are as follows: 

  Asp to asp.net pages: 

  Asp page with one of the session wrote input information, submitted to the asp.net page 
  Trans.asp 
<%
  ''———- Test data ——– 
  Session ( "name") = "srx" 
  Session ( "id") = "1" 
  Session ( "sex") = "f" 
  Session ( "pass") = "asdfas" 
  Session ( "age") = "23" 
  Session (the "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) 
  Response.Write ( "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>") 
%>


  Asptoaspx.aspx 
  <% @ Page language = "c #"%> 
  <script Language=C# runat=server> 
  Private void Page_Load (object sender, System.EventArgs e) 
  ( 
  Session.Timeout = 60; 

  For (int i = 0; i <Request.Form.Count; i + +) 
  ( 
  Session [Request.Form.GetKey (i)] = Request.Form [i]. ToString (); 
  ) 

  Allsession () / / output all the Session, can be used in front of them 

  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 >");// output all the Session, when using comment out 
  ) 
  ) 
  </ Script> 


  Asp.net to asp page: 

  With a asp.net pages, wrote to input information in the session, submitted to the asp page 


  Trans.aspx 
  <% @ Page language = "c #"%> 
  <script Language=C# runat=server> 
  Private void Page_Load (object sender, System.EventArgs e) 
  ( 
  / / Test data ———– ———- 

  Session [ "name"] = "srx"; 
  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>"); 
  ) 
  </ Script> 

  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.Redirect (Session ( "DestPage")) 
  End if 

  '———————– Output all Session ———————- ————————– 

  Call allsession () 'use of this line of code can be commented out 

  Function allsession () 
  Response.Write "There are" & & Session.Contents.Count "Session <I> var </ I> iables <P>" 
  Dim strName, iLoop 
  For Each strName in Session.Contents' Use For Each cycle see Session.Contents 

  If IsArray (Session (strName)) then 'If Session variable is an array?' Print cycle for each element array 
  For iLoop = LBound (Session (strName)) to UBound (Session (strName)) 
  Response.Write strName & "(" & & iLoop ") -" & _ 
  Session (strName) (iLoop) & "<BR>" 
Next
  Else 'other circumstances, the value of simple variables Print 
  Response.Write strName & "-" & Session.Contents (strName) & "<BR>" 
  End If 
Next
  End function 
  '————————————————- —————————————– 
%>
  Code in the process of asp.net pages submitted to the asp page when Server.Transfer method can not be used, but their use Response.Write to write Form forms submitted. 
  Code are also to improve on the prawns Comments please. 

Bookmark it: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Google
  • DotNetKicks
  • DZone
  • Furl
  • Netvouz

Tags: ,

Releated Articles


0 Comments to “Asp sharing session with asp.net”

No Comments. Send your comment.

Leave a Reply

You must be logged in to post a comment.