473,386 Members | 1,752 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,386 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 17 '05 #1
2 1675
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 17 '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 17 '05 #3

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

Similar topics

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...
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: 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...
6
by: Jensen Bredhal | last post by:
Hello, I need to send command to a web server from a method. I understand this should be possible using the WebClient or WebRequest class. how can this be done? below an example of my...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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,...

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.