H
hoenes1
Hi all,
I have an asp.net application from which registered users can download
files. What I want to implement is a bandwidth restriction for certain
users. What I DON'T want to do is restrict the bandwidth on the IIS
side. It really should be handled in the code. Here is a code snippet
showing how downloads are currently handled (standard implementation I
guess):
// fs: FileStream
while (offset < size && Response.IsClientConnected)
{
if (size-offset < bufSize)
{
bufSize = size-offset;
buf = new byte[bufSize];
}
fs.Read(buf, 0, (int)bufSize);
Response.OutputStream.Write(buf, 0, (int)bufSize);
if (Response.IsClientConnected)
Response.Flush();
else
break;
offset += bufSize;
}
everything works fine, but I can't find a way to decrease the speed of
the download (except perhaps adding Sleep() or decreasing bufsize which
would both be a *dirty* solution). Anyone has an idea?
Thanks in advance
Hannes
I have an asp.net application from which registered users can download
files. What I want to implement is a bandwidth restriction for certain
users. What I DON'T want to do is restrict the bandwidth on the IIS
side. It really should be handled in the code. Here is a code snippet
showing how downloads are currently handled (standard implementation I
guess):
// fs: FileStream
while (offset < size && Response.IsClientConnected)
{
if (size-offset < bufSize)
{
bufSize = size-offset;
buf = new byte[bufSize];
}
fs.Read(buf, 0, (int)bufSize);
Response.OutputStream.Write(buf, 0, (int)bufSize);
if (Response.IsClientConnected)
Response.Flush();
else
break;
offset += bufSize;
}
everything works fine, but I can't find a way to decrease the speed of
the download (except perhaps adding Sleep() or decreasing bufsize which
would both be a *dirty* solution). Anyone has an idea?
Thanks in advance
Hannes