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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:08:42+00:00 2026-05-27T18:08:42+00:00

I have custom error handling defined for my application and it all works wonderfully

  • 0

I have custom error handling defined for my application and it all works wonderfully – when a resource cannot be found, the correct ‘NotFound’ view renders. When an unhanlded exception occurs, the ‘ServerError’ view renders.

The problem I am facing is that my application insists on trying to find a View called ‘Error’ but doesn’t find it, as i don’t have one and thus this exception gets thrown during my custom error handling routine:

“The view ‘Error’ or its master was not found or no view engine supports the searched locations. The following locations were searched: … “

I have an Application_Error event handler which does the logging of all unhandled exceptions:

protected void Application_Error(Object sender, EventArgs e)
{
    Exception lastEx = Server.GetLastError();

    // Attempt to Log the error
    try
    {
        Utils.Logger.Error(lastEx);
    }
    catch (Exception loggingEx)
    {
        // Try and write the original ex to the Trace
        Utils.TryTrace(lastEx.Message);

        // Try and write the logging exception to the Trace
        Utils.TryTrace(loggingEx.Message);
    }
}

I have customErrors turned ‘On’ in my web.config:

<customErrors mode="On" defaultRedirect="blah">
    <error statusCode="404" redirect="dee"/>
    <error statusCode="500" redirect="blah"/>
</customErrors>

And i have routes defined in my Global.asax.cs RegisterRoutes method which correspond to the Redirect defined in web.config above:

routes.MapRoute(
    "Error - 404",
    "dee",
    new { controller = "Error", action = "NotFound" }
    );

routes.MapRoute(
    "ServerError", // When this route is matched we want minimal error info displayed
    "blah",
    new { controller = "Error", action = "ServerError" }
    );

I have a BaseController which contains an OnActionExecuted routine:

protected override void OnActionExecuted(ActionExecutedContext filterContext)
{
    Logger.Info(String.Format(Constants.LOG_ACTION_EXECUTED, filterContext.Controller.ToString(), filterContext.ActionDescriptor.ActionName));
    // Log any exceptions
    if (filterContext.Exception != null)
    {
        Stack<string> messages = new Stack<string>();
        Exception current = filterContext.Exception;
        messages.Push(current.Message);
        while (current.InnerException != null)
        {
            messages.Push(current.InnerException.Message);                    
            current = current.InnerException;
        }
        StringBuilder result = new StringBuilder();
        while (messages.Count != 0)
        {
            result.Append(messages.Pop());
            string nextline = messages.Count > 0 ? "OUTER EXCEPTION " + messages.Count + ": " : "";
            result.Append(Environment.NewLine);
        }
        Logger.Error(result.ToString());
    }
    base.OnActionExecuted(filterContext);
}

Is there somewhere else that the Framework defines which view to render in the event of an unhandled exception?

Is my custom error handling routine missing a final step which would ensure that the Framework no longer expects to find the ‘Error’ view???

  • 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-27T18:08:42+00:00Added an answer on May 27, 2026 at 6:08 pm

    I had already removed the line which added the filter automatically to all Controllers…as suggested by Eranga – so that wasn’t what was causing the Framework to search for the ‘Error’ view.

    The problem i was experiencing was being caused by some left over [HandleError] attribute tags sitting on top of one of my Controllers.

    So it is interesting to note that: despite the fact that my controller had the [HandleError] attribute decorated at the top of its class definition, my custom error handling routine, as defined in the web.config, was still being called – and was correctly rendering the required Views…

    The framework error handling (as defined by the HandleErrorAttribute) would fail, my Application_Error would catch the Exception and silently log it to the Database via my ‘Logger’ instance…then my custom error handling routine would complete successfully.

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

Sidebar

Related Questions

I have a website which uses the custom 404 error handling in PHP/Apache to
I have a custom error page set up for my application: <customErrors mode=On defaultRedirect=~/errors/GeneralError.aspx
I have the next problem with wicket and standard error handling: all the css
I have a custom error handler attached to E_ALL PHP errors. In an external
Given that I have a custom PHP error handler already, does it make sense
I'm looking into re-working and simplifying our error handling in an application I support.
I have the following in my web.config <httpErrors errorMode="Custom"> <remove statusCode="500" subStatusCode="-1" /> <error
I have implemented global error handling in my global.asax file to handle any exceptions
I have two static methods that I want to use for error handling. One
In my model I have: validate :my_custom_validation def my_custom_validation errors.add_to_base(error message) if condition.exists? end

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.