473,396 Members | 1,914 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,396 software developers and data experts.

Long files: HttpWebRequest & StreamRead

I'm hoping to grab some 70,000 text files over http using the code
below. For the most part, the files are a few KB in size, and are
downloaded quickly. The code meets its Waterloo, however, with a rare
behemoth of 3 MB. I bumped up the Timeout property to 10 minutes (or, at
least I think I did) in hopes it wouldn't fail, but it fails still.

I'd appreciate any tips to fix the problem!

--Brent
==================================

public string get13f (string strURL)
{
try
{
HttpWebRequest oRequest = (HttpWebRequest)WebRequest.Create(strURL);
oRequest.Timeout = 10*60000; // 10 minutes; for long files (10000 =
10 seconds)
oRequest.UserAgent = "Web Client";
HttpWebResponse oResponse = (HttpWebResponse)oRequest.GetResponse();

Stream myStream = oResponse.GetResponseStream();
StreamReader sr = new StreamReader(myStream);
string strResponse = sr.ReadToEnd();
return strResponse;
myStream.Close();
}
catch
{
return "0";
}
}

==================================
Nov 19 '05 #1
4 1716
Check your maxRequestLength setting.

<httpRuntime executionTimeout="90" maxRequestLength="#ofKBtodownload"

maxRequestLength="8192" would allow 8MB.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Brent" <""b b i g l e r \"@ y a h o o . c o m"> wrote in message
news:11*************@corp.supernews.com...
I'm hoping to grab some 70,000 text files over http using the code below. For the most
part, the files are a few KB in size, and are downloaded quickly. The code meets its
Waterloo, however, with a rare behemoth of 3 MB. I bumped up the Timeout property to 10
minutes (or, at least I think I did) in hopes it wouldn't fail, but it fails still.

I'd appreciate any tips to fix the problem!

--Brent
==================================

public string get13f (string strURL)
{
try
{
HttpWebRequest oRequest = (HttpWebRequest)WebRequest.Create(strURL);
oRequest.Timeout = 10*60000; // 10 minutes; for long files (10000 = 10 seconds)
oRequest.UserAgent = "Web Client";
HttpWebResponse oResponse = (HttpWebResponse)oRequest.GetResponse();

Stream myStream = oResponse.GetResponseStream();
StreamReader sr = new StreamReader(myStream);
string strResponse = sr.ReadToEnd();
return strResponse;
myStream.Close();
}
catch
{
return "0";
}
}

==================================

Nov 19 '05 #2
Check your maxRequestLength setting.

<httpRuntime executionTimeout="90" maxRequestLength="#ofKBtodownload"

maxRequestLength="8192" would allow 8MB.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Brent" <""b b i g l e r \"@ y a h o o . c o m"> wrote in message
news:11*************@corp.supernews.com...
I'm hoping to grab some 70,000 text files over http using the code below. For the most
part, the files are a few KB in size, and are downloaded quickly. The code meets its
Waterloo, however, with a rare behemoth of 3 MB. I bumped up the Timeout property to 10
minutes (or, at least I think I did) in hopes it wouldn't fail, but it fails still.

I'd appreciate any tips to fix the problem!

--Brent
==================================

public string get13f (string strURL)
{
try
{
HttpWebRequest oRequest = (HttpWebRequest)WebRequest.Create(strURL);
oRequest.Timeout = 10*60000; // 10 minutes; for long files (10000 = 10 seconds)
oRequest.UserAgent = "Web Client";
HttpWebResponse oResponse = (HttpWebResponse)oRequest.GetResponse();

Stream myStream = oResponse.GetResponseStream();
StreamReader sr = new StreamReader(myStream);
string strResponse = sr.ReadToEnd();
return strResponse;
myStream.Close();
}
catch
{
return "0";
}
}

==================================

Nov 19 '05 #3
Juan:

Thanks for your help. This is a good suggestion, but I've discovered
the problem is a memory error. I'm going to post another thread on that
error specifically.

Thanks again.

--Brent

Juan T. Llibre wrote:
Check your maxRequestLength setting.

<httpRuntime executionTimeout="90" maxRequestLength="#ofKBtodownload"

maxRequestLength="8192" would allow 8MB.

Nov 19 '05 #4
Juan:

Thanks for your help. This is a good suggestion, but I've discovered
the problem is a memory error. I'm going to post another thread on that
error specifically.

Thanks again.

--Brent

Juan T. Llibre wrote:
Check your maxRequestLength setting.

<httpRuntime executionTimeout="90" maxRequestLength="#ofKBtodownload"

maxRequestLength="8192" would allow 8MB.

Nov 19 '05 #5

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

Similar topics

2
by: Mark Rae | last post by:
Hi, Can anyone please tell me if it's possible to use HttpWebRequest and HttpWebResponse in a class in a Windows application? I've tried referencing System and System.Web but there's still...
3
by: Stig-Arne Basberg | last post by:
I am working on a project where I want to send at file from a Win CE device to a receiving PC using the HTTP protocol. For testing purpose I made a simple test app on my PC (code below). The...
2
by: Paul J. Lay | last post by:
BlankThere are a number of good examples illustrating how an http client can send http mulipart/form-data files to a server using the dotnet.framework.aspnet support. I haven't been able to find a...
0
by: Pmcg | last post by:
I would appreciate any help with the following, havn't found any answers for this in my research to date. I am trying to retreive a web page (a htm file intially) from a vdir on an intranet site...
0
by: Brent | last post by:
I'm hoping to grab some 70,000 text files over http using the code below. For the most part, the files are a few KB in size, and are downloaded quickly. The code meets its Waterloo, however, with a...
4
by: Brent | last post by:
I'd like to think that my code* is pretty simple, but I'm running into memory errors when loading larger documents. The URL you see below in the first line of the Page_Load function is about 3...
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...
15
by: Snedker | last post by:
I'm using (HttpWebRequest and HttpWebResponse to check for updates. But how do I determine the size of the file before download? What I have in mind is a status text like "You have downloaded...
4
by: JVNewbie | last post by:
I'm attempting to test an aspx module that will receive XML data from a web service (the receiver module). I want to be able to test this portion before attempting to create the Web Service that will...
1
by: tregewitz | last post by:
I am uploading a zip file using an HttpWebRequest and a PUT operation to Sharepoint (2003) from a Windows Form application. When I upload the same file using the Sharepoint Portal Web UI itself,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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...

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.