473,804 Members | 3,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.serve rvariables("HTT P_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.Cre ate(sReqURI);
oRequest.Cookie Container = new CookieContainer ();
System.Net.Cook ie oCookie = new System.Net.Cook ie(m_sSessionKe y,
m_sSessionValue );
oCookie.Domain = m_sDomain;
oRequest.Cookie Container.Add(o Cookie);

HttpWebResponse oResponse = (HttpWebRespons e) oRequest.GetRes ponse();

Stream receiveStream = oResponse.GetRe sponseStream();

System.Text.Enc oding encode =
System.Text.Enc oding.GetEncodi ng("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.Clos e();

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 5807
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***@TRASHasp faq.com> wrote in message news:<uR******* *******@TK2MSFT NGP09.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
7135
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 a user from information you got from the session. Each secure app on a site must challenge the user for name and password, each and every time the user accesses it (not just once and then store it in the session). If a secure app is multi-page,...
8
3975
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
2615
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 database. To test, I've created two test aspx pages. Test1.aspx contains two buttons. The first button sets values in the session object and then navigates to Test2.aspx. Test2.aspx only displays the values in the session object. The second button...
6
1238
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 filter (msmdpump.dll), and I've tried a lot, but can't make this works in ASP.NET. Thanks, Ravi.
0
2268
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 updating the code-behind dll) accessing any aspx page in the application causes the application to run for the first time. Some of the initialization involves reading and writing some text and xml files using simple streamreader and streamwriter...
0
1423
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 page to page I need to emulate a browser keeping a session active. I'm currently using the .Net code below to access each web page. If I get back an ASPSESSIONID cookie, I store it in a Cookie object, and keep passing that object back every...
5
4856
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 user close the browser window then open a new browser, FormsAuthentication reads from cookie and user logs in. Althought user logged in, session parameter is null.
9
1962
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 the appropriate session cookie already. After logging in on that page successfully they are given the cookie and redirected back to the page they initially tried to go to. I would like to create a Windows application that gets data from that...
5
1550
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 session and then I use the following code to try and get a stream of image data. mypage.aspx has a different session ID then the calling page. I tried to use a relative URI but the getresponse said it couldn't use a relative uri. I've looked at...
0
9705
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9576
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10074
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9138
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5515
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4291
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.