473,808 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HttpWebRequest With Session

Hi,
I am using HttpWebRequest to get the content of a web page. the call to
this web page is creating a session on the server. then, I wish to get
the content of a 2nd web page on the same site, but this 2nd web page
reads the session created on the 1st page. so when i call it with
HttpWebRequest, it lost the session. anybody has a tip or a code
snippet that shows me how do i make the server retain the session
between two HttpWebRequest calls?

thanks

Aug 14 '06 #1
3 3130
What you need to do is in the response for the first request, there will
be cookies that are sent back. You need to include these cookies as part of
your second request. One of these cookies has an identifier in it which
idenfies the session.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

<yo**@nobhillso ft.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
Hi,
I am using HttpWebRequest to get the content of a web page. the call to
this web page is creating a session on the server. then, I wish to get
the content of a 2nd web page on the same site, but this 2nd web page
reads the session created on the 1st page. so when i call it with
HttpWebRequest, it lost the session. anybody has a tip or a code
snippet that shows me how do i make the server retain the session
between two HttpWebRequest calls?

thanks

Aug 14 '06 #2
This sure helps! what would help more is if you can refer me to any
code sample where its done... do you have anything off the top of your
head... either the online help, an MSDN article or anything like that
where they talk about it? thanks!
Nicholas Paldino [.NET/C# MVP] wrote:
What you need to do is in the response for the first request, there will
be cookies that are sent back. You need to include these cookies as part of
your second request. One of these cookies has an identifier in it which
idenfies the session.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

<yo**@nobhillso ft.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
Hi,
I am using HttpWebRequest to get the content of a web page. the call to
this web page is creating a session on the server. then, I wish to get
the content of a 2nd web page on the same site, but this 2nd web page
reads the session created on the 1st page. so when i call it with
HttpWebRequest, it lost the session. anybody has a tip or a code
snippet that shows me how do i make the server retain the session
between two HttpWebRequest calls?

thanks
Aug 14 '06 #3
Take a look at the CookieContainer property on the HttpWebRequest. You
should be able to assign a new CookieContainer instance to it. Then, the
response should populate a cookie collection in the container. Just make
sure that you store a reference to the CookieContainer so that you can
assign it to the new request.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

<yo**@nobhillso ft.comwrote in message
news:11******** **************@ 74g2000cwt.goog legroups.com...
This sure helps! what would help more is if you can refer me to any
code sample where its done... do you have anything off the top of your
head... either the online help, an MSDN article or anything like that
where they talk about it? thanks!
Nicholas Paldino [.NET/C# MVP] wrote:
>What you need to do is in the response for the first request, there will
be cookies that are sent back. You need to include these cookies as part
of
your second request. One of these cookies has an identifier in it which
idenfies the session.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

<yo**@nobhills oft.comwrote in message
news:11******* *************** @i3g2000cwc.goo glegroups.com.. .
Hi,
I am using HttpWebRequest to get the content of a web page. the call to
this web page is creating a session on the server. then, I wish to get
the content of a 2nd web page on the same site, but this 2nd web page
reads the session created on the 1st page. so when i call it with
HttpWebRequest, it lost the session. anybody has a tip or a code
snippet that shows me how do i make the server retain the session
between two HttpWebRequest calls?

thanks

Aug 14 '06 #4

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

Similar topics

1
14294
by: Craig | last post by:
I wrote a generic page to do HttpWebRequest operations based on 3 querystring parameters for the uri, username, and password for basic authentication pages. The page is designed to help with network management... You would use the page like this: http://localhost/webform1.aspx?uri=http://pagetomonitor.com&user=someuser&pass=somepass Anyway, what seems to happen is that the first 2 or 3 calls to the page with a given set of parameters...
2
4830
by: Keith Patrick | last post by:
I'm trying to programmatically post data to another page within my ASP.Net app. Not POSTing is not an option (I can't store this data in my session, context, hidden fields, or anything else...I've exhausted all my other options, so I have to get this scenario working). Basically, if I POST the data normally, it works fine, except the target page has a new session ID, so I lost the session data that I *do* transfer around. However, if I...
11
15898
by: Keith Patrick | last post by:
Could someone explain to me the relationship between these two classes? I am ripping my hair out trying to divert an HttpRequest to a new location via an HttpWebRequest, but I cannot get my session xfer to work, possibly due to the cookies not being compatible. I've spent over a week trying to get the HWR to integrate nicely with my app, but I cannot get the session to transfer, and it'd probably take me even longer if I tried to digest...
4
404
by: Chris Newby | last post by:
My project currently requires that I integrate an ASP.NET application with an ASP application. One of the issues I'm having is that I have some very long strings being created in an ASP.NET application that need to somehow appear in a classic ASP session. The strings are too long for cookies or URLs and I'd like to avoid using a database or someother temporary server storage. So far what I've come up with is a .NET class that "spoofs" a...
2
7070
by: Xpou | last post by:
Hi, I have a windows form app which makes post httpwebrequests to the same pages of the same web site several times. This web site generates a "phpsessid" which is a session id residing in memory (no file is stored). It is a parameter of the url of the second page : Page1 : http://www.mydomain.com/mystartpage.php Page2 : http;//www.mydomain.com/mysecondpage.php;phsessid=abed12ee65f...
10
29989
by: rlueneberg | last post by:
I am trying to foward the old sessionID using "Session.SessionID" to an HttpWebRequest CookieContainer so that I can capture the requested page session variables but it is not working as it is supposed to. The HttpResponse object always returns a different sessionID from the old one which I am trying to force. Why is objRequest not carrying over the old SessionID? private String ReadHtmlPage(string url) { String result = string.Empty;
1
5690
by: ALA | last post by:
Hi, does anybody know if it is possible to pass the SessionID with a web request by using a cookie so that the invoked page in the same domain can access the session objects of the current user? HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.CookieContainer = new CookieContainer(); HttpCookie sessionCookie = HttpContext.Current.Request.Cookies;
0
1728
by: Crysnon | last post by:
My current goal is to be able to get the HTML source of an ASP.Net page that is hosted locally. Even though I make sure the session id is stored in the cookie container of the HttpWebRequest the Session info does not exist on the requested page (I'm stepping through it on debug and it's Session.SessionID does not equal the ID i'm sending). This causes me to lose the login status and eventually causes an error. My first question: Is there a...
0
1384
by: kgabrys | last post by:
I have an C# Windows application that is to connect to a remote HTTPS website, POST the login, then subsequently POST a file and get the response. There is plenty of code out there that shows this sort of thing, but the finesse of how you use the response HTML to create the needed session cookie for the next request. Here's what happens, I send a request, and reading the response, I get and parse out what would become the session cookie if I...
0
9721
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
9600
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
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10375
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10114
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...
1
7651
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
6880
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();...
1
4331
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
3860
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.