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

WebClient and WebResponse eats up memory


How can I upload a file to a ASP.NET page without having the stream eating
up memory without using a 3rd party component?

How can I download a file from a different webpage without eating up memory
without using a 3rd party component?

Files that are just under 2 Gig.

Using FTP is not an option.

Using WebClient.DownloadData and WebResponse.GetResponseStream appear to
both eat up CPU and memory.

Thanks in advanced for the advice,

Scott

Nov 15 '05 #1
2 3260
ScottO,

To upload and download the file, you should be using HttpWebRequest and
HttpWebResponse. Both of them use a stream to get the data to/from the
server, which should reduce the overall working set that you would use. If
you use WebClient, it is going to return everything in an array at one time,
and for large files, like you have noticed, it can be a real
performance-killer.

You should use GetResponseStream, and read in chunks from the stream,
processing them as you read them.

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

"ScottO" <no****@cox.net> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...

How can I upload a file to a ASP.NET page without having the stream eating
up memory without using a 3rd party component?

How can I download a file from a different webpage without eating up memory without using a 3rd party component?

Files that are just under 2 Gig.

Using FTP is not an option.

Using WebClient.DownloadData and WebResponse.GetResponseStream appear to
both eat up CPU and memory.

Thanks in advanced for the advice,

Scott

Nov 15 '05 #2
Many thanks Nicholas. I will try it and let you know how it turns out...

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:u1**************@tk2msftngp13.phx.gbl...
ScottO,

To upload and download the file, you should be using HttpWebRequest and HttpWebResponse. Both of them use a stream to get the data to/from the
server, which should reduce the overall working set that you would use. If you use WebClient, it is going to return everything in an array at one time, and for large files, like you have noticed, it can be a real
performance-killer.

You should use GetResponseStream, and read in chunks from the stream,
processing them as you read them.

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

"ScottO" <no****@cox.net> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...

How can I upload a file to a ASP.NET page without having the stream eating up memory without using a 3rd party component?

How can I download a file from a different webpage without eating up

memory
without using a 3rd party component?

Files that are just under 2 Gig.

Using FTP is not an option.

Using WebClient.DownloadData and WebResponse.GetResponseStream appear to
both eat up CPU and memory.

Thanks in advanced for the advice,

Scott


Nov 15 '05 #3

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

Similar topics

1
by: Dave | last post by:
To open needed site I have to give my ID and a password. I can use webclient.downloadFile() to load an html text. Is there a way to display this site using an webclient object before calling...
2
by: Max Gattringer | last post by:
Hi, I've got a little problem with the WebClient, I always get a failure while debugging this code: private void menuItem2_Click(object sender, System.EventArgs e) { NameValueCollection...
2
by: ScottO | last post by:
How can I upload a file to a ASP.NET page without having the stream eating up memory without using a 3rd party component? How can I download a file from a different webpage without eating up...
2
by: Earl Teigrob | last post by:
I am loading a page using WebClient using the code below. The thing is that on a redirect, I do not end up knowing where the page was loaded from. I need this information because I am parsing the...
3
by: Manuel | last post by:
I have an asp page ("test.asp") that presents the data it receives from a post.When I try the following code, test.asp doesn't return the values (supposedly) posted to it. If I make a web page with...
0
by: Crirus | last post by:
Have anyone done a new wrap on WebRequest and WebResponse that is similar to WebClient? I only need UploadData functionality of WebClient, and in addition to WebClient I need to set timeout of...
5
by: linn | last post by:
The 'Address' parameter in the WebClient.UploadFile usually comes in the form of ie. http://server/Upload_File.aspx Hence my question, what is exactly the content of this Upload_File.aspx? Am i...
2
by: kkb | last post by:
Hello! First, I'm sorry because of my english... I'll try to be understandable! I've got a strange problem using .NET 2003 C# and I haven't figured it out for a long time. I'm implementing an...
1
by: Mad Scientist Jr | last post by:
For some reason I can't get a WebClient to access an outside URL from behind our firewall. The code works when it runs outside the firewall. I turned on windows authentication in the web.config...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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.