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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:39:27+00:00 2026-05-26T10:39:27+00:00

I follow this article to implement Custom Error Pages and Error Logging. The logging

  • 0

I follow this article to implement Custom Error Pages and Error Logging. The logging works fine. However, the custom error page doesn’t display for ajax request when exception occured, it works for normal http full request, e.g.

http://localhost/MyApp/Report/Create/17/ , work, normal url request

http://localhost/MyApp/Report/CreateUser/17/json, NOT work, using Ajax

ASP.NET MVC HandleError Attribute, Custom Error Pages and Logging Exceptions

 public class BaseController : Controller
    {

 protected override void OnException(ExceptionContext filterContext)
        {
            base.OnException(filterContext);

            _log.Error("Error Logging", filterContext.Exception);

            // Output a nice error page when customErrors's mode = On.
            if (filterContext.HttpContext.IsCustomErrorEnabled)
            {
                filterContext.ExceptionHandled = true;               
                this.View("Error").ExecuteResult(this.ControllerContext);
            }
        }
}

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            //Display custom error page using controller.OnException(), HandleErrorAttribute has to be disabled.
           //filters.Add(new HandleErrorAttribute());
        }

  protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);


        }
}

web.config

<customErrors mode="On">

    </customErrors>

Any idea would very much appreciated.

  • 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-26T10:39:27+00:00Added an answer on May 26, 2026 at 10:39 am

    AJAX request are treated different from standard HTML GET\POST request as the browser does not provide automatic rendering of the result. This would be true for any backend stack (not limited to ASP.Net MVC). So in this case even if response contains complete html for error page (which i doubt ASP.Net MVC does for AJAX calls), the browse would not automatically redirect to error page
    The way to go about it would be to catch exception in AJAX and redirect to the error page from client side.

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

Sidebar

Related Questions

I follow this article to update data to gae localhost server from MySQL. This
I was looking at this article and am struggling to follow the VB.NET example
trying to follow this tutorial http://www.codeguru.com/csharp/csharp/net30/article.php/c15489 I'm not able to select the sql server
I am trying to follow this article: http://robshouse.net/article/xdebug-komodo-and-acquia-drupal-stack-installer I did all of that, yet
After reading this article http://camendesign.com/code/developpeurs_sans_frontieres I have decided to follow what it says and
My question is based on this article . Basically a class can implement a
I follow this rule but some of my colleagues disagree with it and argue
I am trying to follow this tutorial on how to connect to a database
I am trying to follow this example (from p137 of Rob Pickering's Foundations of
I tried to follow this but the default modelbinder let my array null on

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.