473,396 Members | 1,990 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.

Slow download speed, large file

I have a php script that did this before, I want to move it to asp.net

I am getting ~30kbps download speeds with this asp.net code. The php
seems to be lightening fast.

Help!

HttpWebRequest webreq = WebRequest.Create(WMSReq.ToString()) as
HttpWebRequest;
HttpWebResponse webrep = webreq.GetResponse()
as HttpWebResponse;
System.IO.Stream streamResp =
webrep.GetResponseStream();
int readbytes = 0;

Response.ClearContent();
string imgtype = "";

if (fileformat.Substring(0, 1).ToUpper() ==
"P")
{
Response.ContentType = "image/PNG";
}
else if (fileformat.Substring(0, 1).ToUpper()
== "J")
{
Response.ContentType = "image/JPEG";
}
else if (fileformat.Substring(0, 1).ToUpper()
== "T")
{
Response.ContentType = "image/TIF";
}

Response.Buffer =
false;
byte[] responseBuffer = new byte[32768];
Server.ScriptTimeout = 600;
while ((readbytes =
streamResp.Read(responseBuffer, 0, responseBuffer.Length)) 0)
{
if (Response.IsClientConnected == true)
Response.OutputStream.Write(responseBuffer, 0, readbytes);
Response.Flush();
}
streamResp.Close();
Response.End();

Jul 17 '07 #1
1 2356
php is faster, but you should be close. couple things to go faster.

1) turn off page buffering
2) only flush after the loop.
3) if you are just streaming a file use TransmitFile

-- bruce (sqlwork.com)

humbleaptience wrote:
I have a php script that did this before, I want to move it to asp.net

I am getting ~30kbps download speeds with this asp.net code. The php
seems to be lightening fast.

Help!

HttpWebRequest webreq = WebRequest.Create(WMSReq.ToString()) as
HttpWebRequest;
HttpWebResponse webrep = webreq.GetResponse()
as HttpWebResponse;
System.IO.Stream streamResp =
webrep.GetResponseStream();
int readbytes = 0;

Response.ClearContent();
string imgtype = "";

if (fileformat.Substring(0, 1).ToUpper() ==
"P")
{
Response.ContentType = "image/PNG";
}
else if (fileformat.Substring(0, 1).ToUpper()
== "J")
{
Response.ContentType = "image/JPEG";
}
else if (fileformat.Substring(0, 1).ToUpper()
== "T")
{
Response.ContentType = "image/TIF";
}

Response.Buffer =
false;
byte[] responseBuffer = new byte[32768];
Server.ScriptTimeout = 600;
while ((readbytes =
streamResp.Read(responseBuffer, 0, responseBuffer.Length)) 0)
{
if (Response.IsClientConnected == true)
Response.OutputStream.Write(responseBuffer, 0, readbytes);
Response.Flush();
}
streamResp.Close();
Response.End();
Jul 17 '07 #2

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

Similar topics

5
by: Nehal | last post by:
i wanted to created a simple CGI script for uploading files to my http server, and decided to use python for it. it seems to work fine except for one issue: there is a lot of CPU overhead. after...
4
by: Adrian MacNair | last post by:
Hi, I created an image gallery which displays 63 images in a slideshow. The problem is that the show was slow because each image loaded one at a time during the show. No problem right? I just...
7
by: ddsvi78 | last post by:
I am a complete idiot when it comes to access. Now that said, I work for a computer security company and one of our customers came to us with an access problem. They had been running fine for a...
7
by: spike | last post by:
Im writing a program to search for a string in a binary file. And it works. The problem is: It is sooo slow! how can i make it faster? It takes 27 seconds just to search a 5 meg file. I guess it...
3
by: Buddy Ackerman | last post by:
I'm trying to write files directly to the client so that it forces the client to open the Save As dialog box rather than display the file. On some occasions the files are very large (100MB+). On...
6
by: Jatin | last post by:
Hey Guys I have a web application that allows users to download files. But the files are not hosted on the webserver. The files are stored on external servers and are referenced by a URL/URI....
0
by: Michal Seidl | last post by:
Hi, I am trying to download data from remote ftp server connected through GSM modem. The speed is slow 1kB/s. Despite the classic linux ftp client works fine the ftp.retrbinary(),ftpretrlines()...
5
by: Pitaridis Aristotelis | last post by:
I have a large file which has to be downloaded from a user using the Internet Explorer. The problem is that when someone downloads this file, the server slows down and the other users can not see...
0
by: Floris | last post by:
I'm using libcurl to download some content from another webpage. For reasons previously unknown to me all calls are very slow to the point of usual timeout. Now i found curl_getinfo() and retrieved...
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.