473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Accessing ASP Session from ASP.NET via Session cookie

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.servervari ables("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
Jul 19 '05 #1
1 5751
Thanks for the reply. Actually, what I was trying to achieve was
passing the session cookie to asp.net and storing it there. Later, I
would make a call, from asp.net back to the asp page, spoofing out the
session cookie being sent in the asp request in the header, thus
getting back to the original asp session. Does this make my request
clearer?

Thanks,
Dax

"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message news:<uR**************@TK2MSFTNGP09.phx.gbl>...
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.


There is no such thing; they have completely independent sessions. You
cannot match a session cookie between an ASP session and an ASP.NET session,
because they have different SessionIDs (which is the identifier used to
locate the cookie for the user). You might have to pass around an
identifier of some sort on the querystring, to avoid this issue... maybe
avoiding sessions altogether, and persisting "session" data in a database or
something like that...

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate...
8
by: ndsoumah | last post by:
hello guys I'm trying to get access to variables I put in a session variable from another page and it fails... here's the exact situation main file page1.php
3
by: William | last post by:
Hi I have an ASP.NET application that connects to an Access database. Everything works fine except for the Session object. Data in the session object is lost after I've made a call to the...
6
by: Ravi Ambros Wallau | last post by:
Guys: Is there someway that allows a normal (and old) ASP page to access Session _or_ Application data of an ASP.NET page? I can't migrate this ASP page to ASP.NET. This ASP page loads an ISAPI...
0
by: Joergen Bech | last post by:
Fairly new to ASP.NET 1.1. Getting the error below when running application on a web server outside of my control, but only the first time I run it: 1. After a long period of inactivity (or...
0
by: Dave Alvarado | last post by:
I'm working on some code that gathers data from a web interface to one of our servers (classic ASP). The problem is that the site uses session variables to store login information, so to move from...
5
by: Ĺženol Akbulak | last post by:
Hello; I use in my web application FormsAuthentication. Also I use Session state (InProc). When a user logged in, I can read Session parameters. (For example Session). Problem is that, when...
9
by: Justin Engelman | last post by:
Hi, I have a website that uses an ISAPI filter that will redirect anyone going to any page on the site to an SSL login page (on a different website with the same root domain) if they do not have...
5
by: gom | last post by:
I am an amatuer asp.net programmer so I hope this question isn't to dumb. I am having difficulty with my understanding of session state. I have an application that stores some values in the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.