473,666 Members | 2,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HttpWebRequest times out with ASP.NET_Session Id 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_Session ID ) 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.Cook ieCollection m_cookies;
string url="webform2.a spx";

m_webreq = (HttpWebRequest ) WebRequest.Crea te(url);
m_webreq.Cookie Container = new CookieContainer ();

foreach (String cookieName in
System.Web.Http Context.Current .Request.Cookie s)
{
System.Web.Http Cookie cookie =
System.Web.Http Context.Current .Request.Cookie s[cookieName];
System.Net.Cook ie myCookie = new System.Net.Cook ie();
myCookie.Name = cookie.Name;
myCookie.Value = cookie.Value;
myCookie.Domain = this.Context.Re quest.Url.Host;
m_webreq.Cookie Container.Add(m yCookie);
}

m_webreq.Method = "POST";
m_webreq.Timeou t = 20000;
//Times out in the next line if I use POST and have cookies
m_webresp = (HttpWebRespons e)m_webreq.GetR esponse();

StreamReader stream = new StreamReader(m_ webresp.GetResp onseStream(),
System.Text.Enc oding.UTF8);

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

Nov 19 '05 #1
1 2777
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
3213
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 in a variable and make the request again with that cookie as a header value (Digest Authentication). But, the problem we are facing is: That the HttpWebRequest is getting two responses simultaneously, which means that the code should wait after...
1
2463
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 Win2k Server - Forms Authentication is setup with a timeout value of 45 minutes in web.config - Session timeout is set to 45 minutes in web.config
1
2789
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 in a variable and make the request again with that cookie as a header value (Digest Authentication). But, the problem we are facing is: That the HttpWebRequest is getting two responses simultaneously, which means that the code should wait after the...
2
4810
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
15870
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...
0
1509
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 ASP content, and then just writes it to the page. In development and testing, there were no problems. Once deployed to production, after the site runs for a few hours, it starts to slow down and throw countless "Operation Has Timed Out"...
10
29970
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
5656
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;
3
4995
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 web.config: <authentication mode="Forms"> <forms name=".ReMaCRM" loginUrl="~/Login.aspx" defaultUrl="~/Default.aspx" cookieless="AutoDetect" domain="" timeout="10" protection="All" /> </authentication>
0
8440
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
8352
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
8863
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8780
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...
0
8636
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
5661
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
2765
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
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.