473,387 Members | 3,750 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,387 software developers and data experts.

httpwebrequest, cookies, session

Hi Everybody,

I have a problem that is driving me crazy and I am hoping for some help
here.

I am building an application (vb.net, vs2003) that crawls selected websites.
The application works fine except for one thing: Some sites rely on session
cookies and I don't seem to be returning the cookies.

The IIS5 log looks like this when I access the same page with

IE:
12:13:15 192.168.0.2 CLIENT GET /pm4/aboutus.asp - 200 71
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.N ET+CLR+1.0.3705;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.4 0607)
signinfrom=;+ASPSESSIONIDCAABTABS=EMFHLDECGHEEOCJB FMLLMDFD;+ASPSESSIONIDACACQBBS=NMONBFECJPICHEGFGAC FEIJG
-

My Application:
11:40:42 192.168.0.2 CLIENT GET /pm4/aboutus.asp - 200 40
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+Q312461 ;+.NET+CLR+1.0.3705)
- -

As you see the session cookies are missing.

The relevant part of my code looks like this:

Dim req As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461;
..NET CLR 1.0.3705)"
req.CookieContainer = New CookieContainer
req.KeepAlive = True
req.Headers.Set("Pragma", "no-cache")
req.Timeout = 30000
req.ContentType = "application/x-www-form-urlencoded"
Dim ReceiveStream As Stream
Dim encode As Encoding
Dim sr As StreamReader
result = req.GetResponse()
ReceiveStream = result.GetResponseStream()
encode = System.Text.Encoding.GetEncoding("utf-8")
sr = New StreamReader(ReceiveStream, encode)
etc...

If I access a .aspx page it confirms that my application supports cookies,
javascript, etc. It basically accepts that I emulate an IE.
But the cookie thing doesn't work.

What I am doing wrong?

Yours,
Nov 21 '05 #1
0 1321

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

Similar topics

0
by: TJO | last post by:
Can someone at MS please reply to this. I am trying to post data so a web form via ssl with the following code. I keep getting this error: "The underlying connection was closed: Could not...
2
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...
11
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...
1
by: davvel | last post by:
It has been 6 days of re-writing the same code in different ways to try and avoid a getResponse Timeout which haunted me for much too long now. I am trying to do a very simple thing which is...
4
by: Andy Fish | last post by:
Hi, I have a web app that I want to make calls back into itself (preserving the session cookies etc). I am using a System.Net.HttpWebRequest object to make the request, but I am having...
16
by: Cheung, Jeffrey Jing-Yen | last post by:
I have a windows form application that generates a request, downloads an image, and waits the user to enter in login info. Unfortunately, this image is dynamic and based on session data. I have...
0
by: Alex Papadimoulis | last post by:
Hey Group, I'm in the process of converting an ASP-based site to an ASP.NET site and built a control that wraps around an ASP page. The control simply does a GET to the same server to render the...
0
by: Alex Papadimoulis | last post by:
Hey Group, I'm in the process of converting an ASP-based site to an ASP.NET site and built a control that wraps around an ASP page. The control simply does a GET to the same server to render the...
3
by: yoni | last post by:
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,...
10
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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...

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.