473,663 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

asp to asp.net + binary stream => performace issues

Hi,

I have some ASP code to stream a binary file. It works well and looks
something like the original ASP code shown below.

I'm experimenting in creating ZIP files on the fly and am trying to come
up with good ways of streaming binary files using ASP.NET, but I'm
having performance issue. The new ASP.NET code is also shown below. The
performance of this is *terrible*. I get less than 200 KB/s across a
LAN. The original code gives a speed the same as just serving a file of
the hard disk directly.

Can anyone give my some pointers to the correct way to do this sort of
thing?

I have experimented using different buffer sizes or writing out the
whole file in one go with no buffer loop, but it does not seem to make a
difference.

I've only just started to experiment with ASP.NET, so I could be trying
to do this completely the wrong way...

The files are about 10MB in size if that matters.

cheers

dc

ORIGINAL ASP CODE:

<%
Function StreamBinaryFil e(FileName)
Const adTypeBinary = 1
Dim BinaryStream
Set BinaryStream = CreateObject("A DODB.Stream")
BinaryStream.Ty pe = adTypeBinary
BinaryStream.Op en
BinaryStream.Lo adFromFile FileName
Do While Not BinaryStream.EO S
Response.Binary Write BinaryStream.Re ad (1048576)
Response.Flush
Loop
Set BinaryStream = Nothing
End Function

Function SaveBinaryFile( FileName, ContentType)
Response.Buffer = True
Response.Clear
Response.AddHea der "Content-Disposition", _
"attachment ; filename=" & FileName
set fso = Server.CreateOb ject ("Scripting.Fil eSystemObject")
set file = fso.GetFile (Server.MapPath (FileName))
Response.AddHea der "Content-Length", file.Size
Set file = Nothing
Set fso = Nothing
Response.Conten tType = ContentType
StreamBinaryFil e Server.MapPath (FileName)
Response.End
End Function
%>

NEW ASP.NET CODE:

<script language=C# runat=server>
void StreamBinaryFil e (string FileName) {
FileStream BinaryStream = File.OpenRead (FileName);
byte[] buf = new byte[1048576];
while (BinaryStream.R ead (buf, 0, 1048576) > 0) {
Response.Binary Write (buf);
Response.Flush ();
}
BinaryStream.Cl ose ();
}

void SaveBinaryFile (string FileName, string ContentType) {
FileInfo f = new FileInfo (Server.MapPath (FileName));
Response.Buffer Output = true;
Response.Clear ();
Response.AddHea der ("Content-Disposition",
"attachment ; filename=" + FileName);
Response.AddHea der ("Content-Length", f.Length.ToStri ng ());
Response.Conten tType = ContentType;
StreamBinaryFil e (f.FullName);
Response.End ();
}
</script>
Jan 27 '06 #1
0 1156

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

Similar topics

27
4928
by: Eric | last post by:
Assume that disk space is not an issue (the files will be small < 5k in general for the purpose of storing preferences) Assume that transportation to another OS may never occur. Are there any solid reasons to prefer text files over binary files files?
103
48598
by: Steven T. Hatton | last post by:
§27.4.2.1.4 Type ios_base::openmode Says this about the std::ios::binary openmode flag: *binary*: perform input and output in binary mode (as opposed to text mode) And that is basically _all_ it says about it. What the heck does the binary flag mean? -- If our hypothesis is about anything and not about some one or more particular things, then our deductions constitute mathematics. Thus mathematics may be defined as the subject in...
8
9512
by: Yeow | last post by:
hello, i was trying to use the fread function on SunOS and ran into some trouble. i made a simple test as follows: i'm trying to read in a binary file (generated from a fortran code) that contains the following three floating-point numbers: 1.0 2.0 3.0
2
3373
by: dansan | last post by:
I have been tryning to make some of our C# programs talk to some perl programs. These perl jewels output in binary. I have been trying to use Process.StandardOutput to read the output from the perl programs. I am able to read the output if it is ASCII (or some char of some sort). But the issues comes when it is binary info. I have tried to use StandardOutput.BaseStream, which returns a Stream to then read the bytes out of that...
2
4626
by: gauravkhanna | last post by:
Hi All I need some help for the below problem: Scenario We need to send large binary files (audio file of about 10 MB or so) from the client machine (.Net Windows based application, located outside the home network) to the Web Server and then retrieve the file back from the web server to the client.
6
2714
by: | last post by:
Hi all, is there a better way to stream binary data stored in a table in sql 2005 to a browser in .net 2.0? Or is the code same as in .net 1.1? We noticed that in certain heavy load scenarios, every now and then the client would timeout and have to re-initiate the request... TIA!
2
2500
by: Wayne Marsh | last post by:
Hello, Is it considered sane/good practice to write a global operator for the insertion and extraction operators of an fstream in binary mode to serialize a binary class, or are they strictly meant for formatted text input and output? Let's imagine, for example, that I had a standard Windows BMP file (I am aware that C++ has no concept of a BMP - this is simply putting my question in a simple context). If I wanted to load it into a...
1
2592
by: Michael | last post by:
I have a solution for this, but it feels wrong. If anyone could offer a better one, I'm all ears. (Or technically, eyes.) Basically, I have a bunch of classes. For concreteness, one is a Matrix class, but that's only one example, so please don't get too hung up on it. I need to output and input these classes. I'd like a nice, pretty, human readable output, something like: 1 2 3
0
1066
by: Michael B. Trausch | last post by:
I am attempting to piece together a Python client for Fotobilder, the picture management server on Livejournal. The protocol calls for binary data to be transmitted, and I cannot seem to be able to do it, because I get this error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "scrapbook.py", line 181, in UploadSinglePicture {Request: pic_mem})
0
8435
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
8345
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
8857
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
8633
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
7368
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4348
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
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
1754
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.