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 8553757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:43:35+00:00 2026-06-11T14:43:35+00:00

Things I already know about upload size limits in MVC: For IIS7 you have

  • 0

Things I already know about upload size limits in MVC:

  1. For IIS7 you have to set both maxAllowedContentLength and maxRequestLength for a max upload size
  2. I know 1 property is in bytes and the other in kilobytes
  3. You can use the location property to specify a fixed location

I have an upload component which should be able to handle up to 200MB files. I dont think its right to set the maxlimit for every single page to 200MB so i want to use the dynamic request URL as location.

The routing pattern for the upload URL is something like this: {dynamicvalue}/ConvertModule/Upload

(“ConvertModule” is the controller and “Upload” is the action.) The hard part is {dynamicvalue}, because of this i cant set a fixed location in web.config.

I don’t want to use flash uploads or something like that as a solution because of session hijacking.

  • Question 1 (most important to me): Is there a way to set the upload limit for the giving routing pattern only?
  • Question 2: Is it possible to show a custom warning when the upload size was exceeded?
  • 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-11T14:43:36+00:00Added an answer on June 11, 2026 at 2:43 pm

    Question 1: Is there a way to set the upload limit for the giving routing pattern only?

    Not that I am aware of because the <location> node doesn’t support dynamic urls. But you could cheat it by using the url rewrite module.

    So let’s suppose that you have a controller handling file uploads:

    public class PicturesController
    {
        [HttpPost]
        public ActionResult Upload(HttpPostedFileBase file, int dynamicValue)
        {
            ...
        }
    }
    

    and that you have some route configured to match to this controller:

    routes.MapRoute(
        "Upload",
        "{dynamicvalue}/ConvertModule/Upload",
        new { controller = "Pictures", action = "Upload" },
        new { dynamicvalue = @"^[0-9]+$" }
    );
    

    OK, now let’s setup the following rewrite rule in web.config:

    <system.webServer>
        <rewrite>
          <rules>
            <clear />
            <rule name="rewrite the file upload path" enabled="true">
              <match url="^([0-9]+)/ConvertModule/Upload$" />
              <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
              <action type="Rewrite" url="pictures/upload?dynamicvalue={R:1}" />
            </rule>
          </rules>
        </rewrite>
    </system.webServer>
    

    So far so good, now you could setup the <location> to pictures/upload:

    <location path="pictures/upload">
        <system.web>
            <!-- Limit to 200MB -->
            <httpRuntime maxRequestLength="204800" />
        </system.web>
        <system.webServer>
            <security>
                <requestFiltering>
                    <!-- Limit to 200MB -->
                    <requestLimits maxAllowedContentLength="209715200" />
                </requestFiltering>
            </security>
        </system.webServer>
    </location>
    

    Now you could upload to an url of the following pattern: {dynamicvalue}/ConvertModule/Upload and the url rewrite module will rewrite it to pictures/upload?dynamicvalue={dynamicvalue} but the <location> tag will match pictures/upload and successfully apply the limit:

    <form action="/123/ConvertModule/Upload" method="post" enctype="multipart/form-data">
        <input type="file" name="file" />
        <button type="submit">OK</button>
    </form>
    

    Question 2: Is it possible to show a custom warning when the upload size was exceeded?

    No, you will have to set the limit to a larger value and inside your upload handler check for the file size. And if you can check the file size on the client (HTML5, Flash, Silverlight, …) then do it to avoid wasting bandwidth.

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

Sidebar

Related Questions

I'm designing an MVC site, and I've already got quite a few things in
There's 12 million posts already and people seem to be using things as a
Strange things happen. I can start Tomcat from both Eclipse and startup.sh. Runnig from
Two things: Firstly - I have version 2 of a website located in a
Does anyone know if there is a php library, or if there isnt, have
Are there any good tutorials or resources online for learning HTML5? I already know
I just have a quick question about how to generate id's on-the-fly for HTML
I know questions like this have been asked before, and I've viewed a lot
i'm daily in the process of learning new things about Rails (started learning 2
I recently started learning about ASP.Net MVC and its various features MVC_3_MUSIC_STORE + CODE

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.