2B9A75E094B1481CA4C981324462D53F
  • Internet
  • 27.12.2017
  • EN

Simply RedDot: "ASP to .NET Session Transfer".

written by Jian Huang, 10. April 2012
 

Generally, there are two ways to transfer ASP sessions to .NET sessions. Also, these methods are not limited to reddot/opentext wsm/cms, but are useful in general day to day coding. Please note that the code illustrations do not take security concerns into consideration, securing session access can be achieved via IIS configuration or addition code checking. 
 

Push Method

session_transfer.asp 

<%
Dim sActionPageURL, sContent
 
sActionPageURL = "http://localhost/cms/plugins/session_store.aspx"
sContent = "?"
 
For Each Item In Session.Contents
 sContent = sContent & Item & "=" & server.URLencode(Session.Contents(item)) & "&"
Next
 
'Construct POST Object
set http_obj=server.CreateObject("MSXML2.ServerXMLHTTP")
http_obj.Open "POST", sActionPageURL , false
http_obj.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
http_obj.send(sContent)
 
'Display Response
'Response.Write (http_obj.ResponseText)
 
set http_obj=nothing
%>

session_store.aspx

<%@ Page language="c#" validateRequest="false"%>
<%
    for(int i=0;i<Request.Form.Count;i++)
    {
        Session[Request.Form.GetKey(i)]=Request.Form[i].ToString();
        'Response.Write(Request.Form.GetKey(i));
        'Response.Write("=");
        'Response.Write(Session[Request.Form.GetKey(i)]);
    }
  
    Response.Write(Session.Count);
%>

Source: ASP to .NET Session Transfer

© copyright 2012 by Jian Huang