Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8757867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:24:19+00:00 2026-06-13T14:24:19+00:00

I have read this article on Codeproject, but I don’t know how to apply

  • 0

I have read this article on Codeproject, but I don’t know how to apply it to asp.net MVC 3
http://www.codeproject.com/Articles/18243/Bandwidth-throttling

Here is the code for downloading a file in my project

public ActionResult GetFile(int id)
{
    var f = FileAcc.GetInfo(id);
    var templateStr = new FileStream(Server.MapPath(f.file_url), FileMode.Open);
    return File(templateStr, f.file_name);
}

Please support me on this issue; thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:24:20+00:00Added an answer on June 13, 2026 at 2:24 pm

    Include ThrottledStream.cs in your project and replace your GetFile method with the following –

    public ActionResult GetFile(int id) {
        var f = FileAcc.GetInfo(id);
            int bufferSize = 1024, bps = 1024;
            using (FileStream sourceStream = new FileStream(Server.MapPath(f.file_url), FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize)) {
                using (Born2Code.Net.ThrottledStream destinationStream = new Born2Code.Net.ThrottledStream(Response.OutputStream, bps)) {
                    byte[] buffer = new byte[bufferSize];
                    int readCount = sourceStream.Read(buffer, 0, bufferSize);
                    Response.Buffer = false;
                    while (readCount > 0) {
                        destinationStream.Write(buffer, 0, readCount);
                        readCount = sourceStream.Read(buffer, 0, bufferSize);
                    }
                }
            }
        return new EmptyResult();
    }
    

    And tweak bps per your need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am teaching myself asp .net mvc 3. I read this tutorial: http://www.codeproject.com/Articles/148949/ASP-NET-MVC-3-the-Razor-View-Engine-and-Google-Map and
I have read this article http://weblogs.asp.net/scottgu/archive/2009/09/15/auto-start-asp-net-applications-vs-2010-and-net-4-0-series.aspx about auto-start mode in asp.net4.0 and still don't
I have a silly question. I read this article about std::exception http://www.cplusplus.com/doc/tutorial/exceptions/ On catch
I have read from this article http://codahale.com/how-to-safely-store-a-password/ and it says using a salt isn't
I read http://www.codeproject.com/KB/architecture/MVC_MVP_MVVM_design.aspx and it said: As powerful as they are, both MVC and
I have read this article http://codebetter.com/iancooper/2011/10/06/avoid-testing-implementation-details-test-behaviours/ And I am confusing about Code developed in
I have read this article from High Scalability about Stack Overflow and other large
I have read this article about 400% boost of your website . This is
First let me say I have read this useful article thoroughly and am using
I have previously read Spolsky's article on character-encoding, as well as this from dive

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.