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

  • SEARCH
  • Home
  • 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 4071480
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:45:43+00:00 2026-05-20T16:45:43+00:00

I want to show a custom error page if a user tries to upload

  • 0

I want to show a custom error page if a user tries to upload a file larger than the maximum request length.

With no code at all, I get a very mysterious “The page cannot be displayed” error when uploading a large file (not the famous yellow ASP error page) — the same sort of browser error you get when you’re offline. This strikes me as weird, and probably has something to do with this problem.

I added this to my Global.asax file:

  //simplification
  public void Application_Error(object sender, EventArgs e)
  {
      Response.Redirect("http://www.google.com", false); //This IS getting hit
  }

Custom errors are off in my Web.config file (and must stay that way).

Seems pretty simple, right? But for whatever reason, that redirect just isn’t doing anything. It is getting hit. It is executing that line. I have tried it with endResponse set to true as well; no difference.

I’ve tried with the following two lines before the redirect:

Response.Clear();
Server.ClearError();

The first I assume would address a redirect occurring after headers had been sent (which is not the case); the second I’m not really sure what difference that would make, but I have seen this code in similar StackOverflow questions/answers, so I thought I’d try it.

So — is there something peculiar about this particular error that makes redirects impossible?

If you’d like to try it for yourself (and see what I mean about the weird error non-page), here’s some quick copypasta to add to VS’s standard MVC app:

Views -> Home -> Index.aspx

<asp:Content ContentPlaceHolderID="MainContent" runat="server">
    <form enctype="multipart/form-data" method="post" action="<%= Url.Action("Upload") %>">
      <input type="file" name="required-to-post" />
      <input type="submit" value="Upload" />
    </form>
</asp:Content>

Controllers -> HomeController.cs

public ActionResult Upload()
{
    return View("Index");
}

Global.asax

protected void Application_Error()
{
    Response.Redirect("http://www.google.com", false);
}

Then just upload a large file (5mb) and it ought give this mysterious error (without redirecting).

  • 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-05-20T16:45:44+00:00Added an answer on May 20, 2026 at 4:45 pm

    This is a pretty old question, and one that I solved a while ago, although I never posted an answer here.

    If I recall correctly, the problem was actually with the IIS server, not the MVC app. The server itself had a maximum request length, and things behaved very strangely when this rule was violated.

    By changing the maximum server request size, I believe that the problem disappeared. But I don’t know if this is possible in the local server that VS fires up when you try to debug an MVC app.

    In any case, I believe that I was doing something fundamentally wrong by trying to allow large file upload through an HTML form. I instead implemented an asynchronous file uploader so that I don’t have to worry about this — it provides a much better user epxerience, and I don’t have to scratch my head over this any more.

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

Sidebar

Related Questions

I want to show a custom error page on Joomla for error messages like
I want to display a custom error page: <!doctype html> <html> <head><title>400 Bad Request</title></head>
Want to show a custom message in form's error list, if the two fields
I want to create a custom error page to handle all unhandled exceptions. I
I am using Delphi, and I want to show custom text in the buttons
I want to show a custom image with some data in it while clicking
I want to show my custom objects (images, formulas) in UITableView row name. Is
I want my Application to show Custom Dialog When an Uncatch Exception occur. For
I have a custom control (C#, visual studio). I want to show a tooltip
I want show an information page after success db opartions. And after the info

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.