473,320 Members | 2,097 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,320 software developers and data experts.

HttpWebRequest times out with ASP.NET_SessionId cookie (response TIMEOUT)

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 prooving the most
difficult in my career. Scrape a screen which has several session
variables within it, and send this page to an e-mail.

I have two pages in my application webform1.aspx and webform2.aspx, in
webform1.aspx I set several session variables which when one goes to
webform2.aspx will be displayed in varies places. Going to
webform2.aspx through the normal browser works ok.

Now I write a very simple screen scraper using httpWebRequest pointing
to webform2.aspx, I pass the necessary cookies in the header to
maintain session state and the page times out on me. If I don't pass
the session cookie ( ASP.NET_SessionID ) then the page is scraped but
of course the session variables are all null.
Can anyone tell me if I can scrape a page within my application without
using htppwebrequest or else if there is a known bug / trick on how to
read the current session ID (I read it from this.Context ) and pass it
over to the webform2.aspx.

One version of my code...

HttpWebRequest m_webreq;
HttpWebResponse m_webresp;
string m_response;
System.Net.CookieCollection m_cookies;
string url="webform2.aspx";

m_webreq = (HttpWebRequest) WebRequest.Create(url);
m_webreq.CookieContainer = new CookieContainer();

foreach (String cookieName in
System.Web.HttpContext.Current.Request.Cookies)
{
System.Web.HttpCookie cookie =
System.Web.HttpContext.Current.Request.Cookies[cookieName];
System.Net.Cookie myCookie = new System.Net.Cookie();
myCookie.Name = cookie.Name;
myCookie.Value = cookie.Value;
myCookie.Domain = this.Context.Request.Url.Host;
m_webreq.CookieContainer.Add(myCookie);
}

m_webreq.Method = "POST";
m_webreq.Timeout = 20000;
//Times out in the next line if I use POST and have cookies
m_webresp = (HttpWebResponse)m_webreq.GetResponse();

StreamReader stream = new StreamReader(m_webresp.GetResponseStream(),
System.Text.Encoding.UTF8);

//m_response is never filled with the page that I need
m_response = stream.ReadToEnd();
stream.Close();
m_webresp.Close();

Nov 19 '05 #1
1 2759
Case Closed. One can user Server.Execute for this.
Nov 19 '05 #2

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

Similar topics

1
by: Satinderpal Singh | last post by:
Hi everyone, We are using HttpWebRequest to create a request to a URI, which requires us to login first. In order to process all the transactions, first we have to login and get the cookie value...
1
by: Scott | last post by:
Hi, We're having an issue with Forms Authentication cookies being treated as expired / invalid, and being deleted. This is causing our intranet users a great deal of pain - Running IIS 5.0 on...
1
by: Satinderpal Singh | last post by:
Hi everyone, We are using HttpWebRequest to create a request to a URI, which requires us to login first. In order to process all the transactions, first we have to login and get the cookie value...
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...
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...
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...
1
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?...
3
by: dihola | last post by:
Hi, I have a website running in IIS7 and it seems to be creating a new session for every request I make. The values I store in Session are lost with every request. This is the forms bit in my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.