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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:52:07+00:00 2026-05-17T18:52:07+00:00

Hell, I have error handling for my mvc app configured in the simplified way

  • 0

Hell,

I have error handling for my mvc app configured in the simplified way below (globals.asax):

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

         Response.Clear();         
         RouteData routeData = new RouteData();
         routeData.Values.Add("controller", "Error");
         routeData.Values.Add("action", "General");            
         routeData.Values.Add("exc", exception);
         Server.ClearError();
         using (ErrorController errorController = new ErrorController())
         {
            ((IController)errorController).Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
         }         
      }

Above, I’m dynamically creating route for the controller. It is useful, because I can pass the Exception object to controller action. This is just simplified version shown above, because normally I’m creating different routes for various exception types. I have NO static route defined especially for error handling in function RegisterRoutes. This function is untouched:

 public static void RegisterRoutes(RouteCollection routes)
 {
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.MapRoute(
            "Default",
            "{controller}/{action}/{id}",
            new {controller = "Home", action = "Index", id = ""}
            );
 }

My simplified controller looks like that:

public class ErrorController : Controller
   {
      public ActionResult General(Exception exc)
      {
         ViewData["ErrorDetails"] = exc.ToString();
         return View("Error");
      }
}

Suppose, I have an error prone site:

http://localhost/app/site/wtf.

When I’m testing error handling locally, everything is fine. ErrorController is invoking General action, and this action renders Error view.

But when I’m invoking this error prone site from another host, for example, the application is deployed on nice.host.org server:

http://nice.host.org/app/site/wtf,

I’m getting such exception:

System.InvalidOperationException: The view 'Error' or its master was not found. The following locations were searched:
~/Views/DynamicPage/Error.aspx
~/Views/DynamicPage/Error.ascx
~/Views/Shared/Error.aspx
~/Views/Shared/Error.ascx
~/Views/DynamicPage/Error.cshtml
~/Views/Shared/Error.cshtml
   at System.Web.Mvc.ViewResult.FindView(ControllerContext context)
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.ExecuteCore()
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

What is going on ? How to make this work as expected ?

UPDATE

I’ll provide some additional info just in case.

I’m using razor view engine. In the properties window of Error.cshtml view file, I’ve tried to set Build Action to None or to Content, but the behaviour of the app is still broken, despite which option is selected.

When it comes to pages section in main web.config file, it looks following:

<pages>
  <namespaces>
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Routing" />
    <add namespace="MvcSiteMapProvider.Web.Html" />
  </namespaces>
</pages>

and in the second web.config:

<pages
        validateRequest="false"
        pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <controls>
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
      </controls>
</pages>

I’ll appreciate any clue.

Regards

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

    I’ve found the problem. I had to add such entry to web.config

    <customErrors mode="Off" /> 
    

    There are three error modes in customErrors configuration: On, Off and RemoteOnly. The mode attribute specifies whether custom errors are enabled, disabled, or shown only to remote clients.

    On – Specifies that custom errors are enabled. If no defaultRedirect attribute is specified, users see a generic error. The custom errors are shown to the remote clients and to the local host.

    Off – Specifies that custom errors are disabled. The detailed ASP.NET errors are shown to the remote clients and to the local host.

    RemoteOnly – Specifies that custom errors are shown only to the remote clients, and that ASP.NET errors are shown to the local host.

    By default, the mode value is set to RemoteOnly.

    Previously I had no config entry for customErrors in web.config, so default mode was turned on. When there was an error in a view itself, it was resulting in a redirect to default customErrors url – Error.aspx, which was in turn resulting in previously shown exception:

    System.InvalidOperationException: The view 'Error' or its master was not found. The following locations were searched:
    ~/Views/DynamicPage/Error.aspx
    ~/Views/DynamicPage/Error.ascx
    ~/Views/Shared/Error.aspx
    ~/Views/Shared/Error.ascx
    ~/Views/DynamicPage/Error.cshtml
    ~/Views/Shared/Error.cshtml
    

    This exception was next handled by ErrorController and shown to user.

    Now it’s ok.

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

Sidebar

Related Questions

I have an MVC route that is giving me hell on a staging server
This is a simple script I have written to test command line argument handling:
I have a strange problem regarding Flash error 1151: A conflict exists with definition
This should be simple. Yet, it's giving me Hell. Problem I have compiled the
I have a MVC website and when I execute it, the query string (url)
I have an application that I'm building that has had concurrency problems in the
This is my situation:     I have a linux server/media center with a
I have some code that has a dynamic-class system in C++ that has a
I have some strings that are valid in my database but when I include
I'm having a hell of a time trying to debug some kind of memory

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.