D
Dax Westerman
I have a site that I'm trying to migrate to ASP.NET from ASP, and the
foremost stumbling block I'm hitting is session state between the ASP
and ASP.NET applications. In order to access this information, I'm
doing a HttpWebRequest from the ASP.NET side into an .asp page,
passing the session name on the get in order to request it from the
ASP side and write it back to the response stream, giving ASP.NET
access to it. Of course I change sessions each time I make the call
from the ASP.NET side.
Soooooo, I'm thinking to myself, "Self, shouldn't you be able to fake
out the server by getting the session cookie from the initial usage of
the asp, pass that data to the ASP.NET, and use that to send a request
back the ASP side under the appropriate session?"
From a real high level, I enter the site via a .asp page. This page
in turn calls .aspx page from within a frame
<frame src="init.aspx?SessionCookie=<%=request.servervariables("HTTP_COOKIE")%>">
init.aspx calls a class that makes the call to the session lookup page
(called lookup.asp). The gist is as follows (rough draft):
string sReqURI = . . . defined to pass along the request on the get
HttpWebRequest oRequest = (HttpWebRequest)WebRequest.Create(sReqURI);
oRequest.CookieContainer = new CookieContainer();
System.Net.Cookie oCookie = new System.Net.Cookie(m_sSessionKey,
m_sSessionValue);
oCookie.Domain = m_sDomain;
oRequest.CookieContainer.Add(oCookie);
HttpWebResponse oResponse = (HttpWebResponse) oRequest.GetResponse();
Stream receiveStream = oResponse.GetResponseStream();
System.Text.Encoding encode =
System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader( receiveStream, encode );
char[] read = new char[256];
// Reads 256 characters at a time.
int count = readStream.Read( read, 0, 256 );
while (count > 0)
{
// Dumps the 256 characters on a string and displays the string to the
console.
sValue = new String(read, 0, count);
count = readStream.Read(read, 0, 256);
}
// Releases the resources of the response.
oResponse.Close();
// Releases the resources of the Stream.
readStream.Close();
I can get a response, and if I set actual text in the asp page, I can
retrieve it, so I know that's fine. Can't access the previous
session, though. Anybody have any experience along these lines?
Thanks,
Dax
foremost stumbling block I'm hitting is session state between the ASP
and ASP.NET applications. In order to access this information, I'm
doing a HttpWebRequest from the ASP.NET side into an .asp page,
passing the session name on the get in order to request it from the
ASP side and write it back to the response stream, giving ASP.NET
access to it. Of course I change sessions each time I make the call
from the ASP.NET side.
Soooooo, I'm thinking to myself, "Self, shouldn't you be able to fake
out the server by getting the session cookie from the initial usage of
the asp, pass that data to the ASP.NET, and use that to send a request
back the ASP side under the appropriate session?"
From a real high level, I enter the site via a .asp page. This page
in turn calls .aspx page from within a frame
<frame src="init.aspx?SessionCookie=<%=request.servervariables("HTTP_COOKIE")%>">
init.aspx calls a class that makes the call to the session lookup page
(called lookup.asp). The gist is as follows (rough draft):
string sReqURI = . . . defined to pass along the request on the get
HttpWebRequest oRequest = (HttpWebRequest)WebRequest.Create(sReqURI);
oRequest.CookieContainer = new CookieContainer();
System.Net.Cookie oCookie = new System.Net.Cookie(m_sSessionKey,
m_sSessionValue);
oCookie.Domain = m_sDomain;
oRequest.CookieContainer.Add(oCookie);
HttpWebResponse oResponse = (HttpWebResponse) oRequest.GetResponse();
Stream receiveStream = oResponse.GetResponseStream();
System.Text.Encoding encode =
System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader( receiveStream, encode );
char[] read = new char[256];
// Reads 256 characters at a time.
int count = readStream.Read( read, 0, 256 );
while (count > 0)
{
// Dumps the 256 characters on a string and displays the string to the
console.
sValue = new String(read, 0, count);
count = readStream.Read(read, 0, 256);
}
// Releases the resources of the response.
oResponse.Close();
// Releases the resources of the Stream.
readStream.Close();
I can get a response, and if I set actual text in the asp page, I can
retrieve it, so I know that's fine. Can't access the previous
session, though. Anybody have any experience along these lines?
Thanks,
Dax