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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:41:33+00:00 2026-06-05T16:41:33+00:00

I have an MVC4 site with a nice customError page that works great if

  • 0

I have an MVC4 site with a nice customError page that works great if you have friendly errors turned off in IE but doesn’t show if you have friendly errors turned on. I don’t know why MVC4 would return a 500 when it should just show my error page, but there it is. Here is an example (I had to make it code because SO flipped out at the IP number):

http://192.52.51.45/web/Trip/Index/f32e4bc5-9e06-4bb8-8d43-d43b8c9a014c

What is the configuration change I need to make to have the site return a 200 and just show my error page? Right not the only change I have from the default Web.config is the customErrors:

<customErrors mode="On" />

Thanks for the help.

  • 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-05T16:41:35+00:00Added an answer on June 5, 2026 at 4:41 pm

    That’s how the [HandleError] global attribute is implemented:

    public virtual void OnException(ExceptionContext filterContext)
    {
        if (filterContext == null)
        {
            throw new ArgumentNullException("filterContext");
        }
        if (!filterContext.IsChildAction && (!filterContext.ExceptionHandled && filterContext.HttpContext.IsCustomErrorEnabled))
        {
            Exception innerException = filterContext.Exception;
            if ((new HttpException(null, innerException).GetHttpCode() == 500) && this.ExceptionType.IsInstanceOfType(innerException))
            {
                string controllerName = (string) filterContext.RouteData.Values["controller"];
                string actionName = (string) filterContext.RouteData.Values["action"];
                HandleErrorInfo model = new HandleErrorInfo(filterContext.Exception, controllerName, actionName);
                ViewResult result = new ViewResult {
                    ViewName = this.View,
                    MasterName = this.Master,
                    ViewData = new ViewDataDictionary<HandleErrorInfo>(model),
                    TempData = filterContext.Controller.TempData
                };
                filterContext.Result = result;
                filterContext.ExceptionHandled = true;
                filterContext.HttpContext.Response.Clear();
                filterContext.HttpContext.Response.StatusCode = 500;
                filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;
            }
        }
    }
    

    Notice how it sets the status code to 500 and renders the ~/Views/Shared/Error.cshtml view. All this happens when custom errors are enabled.

    And this by the way is the semantically correct HTTP status code to be used in this exceptional case. Or 404 if you haven’t found the requested resource. 200 should be used only if the server successfully processed the user request.

    If for some reason you don’t like this behavior you could always write a custom global error handling attribute and replace the default one (which is registered inside ~/App_Start/FilterConfig.cs -> filters.Add(new HandleErrorAttribute());).

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

Sidebar

Related Questions

I have 3 mvc4 sites. Site 1 'www.mydomain.com' is a marketing site that allows
I have a ASP.NET MVC4 web api that uses fluent NHibernate, but when I
I have an ASP.NET MVC4 site with custom user/role provider. Entity Framework works with
I have a single page application written in MVC4 that uses pjax() to push
I have a web site built using ASP.NET MVC4 that I can publish fine
I have an ASP.NET MVC4 site with mobile content. When I deploy this on
I have a c# mvc4 twitter bootstap appharbor web site. Currently I use Vimeo
I have a ASP.NET MVC 4 application with Web API. It's working great. But
I am working on creating a MVC4 multi-tenant site that uses seperate DBs for
I have integrated ASP.NET MVC 4 into existing asp.net web site. Both works fine

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.