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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:35:29+00:00 2026-06-08T23:35:29+00:00

I want to custom error pages in my asp.net mvc3 website. So, I found

  • 0

I want to custom error pages in my asp.net mvc3 website.

So, I found this very useful post: Custom error pages on asp.net MVC3 and it works well

However, my Http404.cshtml file isn’t in the Views default folder. It is in a folder named BaseViews.
I already have my _Layout.cshtml and other views or partial views in that folder.

This folder isn’t checked by the default ViewEngine (it only checks the Views folder and all the views folder of my Areas). So, I use a ViewEngineExtension and add it to the System.Web.Mvc.ViewEngines collection in my Global.asax‘s Application_Start(). All my application works perfectly fine and can access my layout and other BaseViews stuff.

I cannot tell the same about the Global.asax‘s Application_Error(). This method ignore the previous view engine and only looks into the default view folder.
I tried to add my ViewEngineExtension in the Application_Error() method like so ViewEngines.Engines.Add(new BaseViewsEngineExtension()); but it doesn’t change anything. It’s exactly the same line I use in the Application_Start().

See my code for the Application_Error():

protected void Application_Error()
{
    var exception = Server.GetLastError();
    var httpException = exception as HttpException;
    Response.Clear();
    Server.ClearError();
    var routeData = new RouteData();
    routeData.Values["controller"] = "Error";
    routeData.Values["action"] = "Index";
    routeData.Values["exception"] = exception;
    Response.StatusCode = 500;
    if (httpException != null)
    {
        Response.StatusCode = httpException.GetHttpCode();
        switch (Response.StatusCode)
        {
            case 404:
                routeData.Values["action"] = "Http404";
                break;
        }
    }

    IController errorController = new ErrorController();
    var rc = new RequestContext(new HttpContextWrapper(Context), routeData);
    errorController.Execute(rc);
}

My question is: How can I force errorController.Excecute(rc) view engine to search my Http404.cshtml view in the BaseViews folder ?

  • 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-08T23:35:31+00:00Added an answer on June 8, 2026 at 11:35 pm

    As SLaks said, you should return the full path of your view in your ErrorController.

      public class ErrorController : Controller
      {
          public ActionResult Http404()
          {
              return View("~/BaseViews/Error/Http404.cshtml");
          }
      }
    

    But it won’t work because your error is overriden, so you don’t get the result expected.
    To bypass this problem, you can tell your application that everything is OK in your application_error with this:

    Request.StatusCode = 200;
    

    I hope it’ll resolve your problem.

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

Sidebar

Related Questions

In my ASP.NET web application, I have defined custom error pages in my web.config
I have an ASP.NET Website. I want to restrict the Admin Folder to only
I created this Custom Route Class in ASP.NET MVC: public class UserAgentConstraint:IRouteConstraint { private
I have created a custom CreateUser in Asp.Net Membership. Now what i want is
I'm trying to have an asp.net custom control with a field like: <ErrorTemplate> <h1>Error</h1>
im trying to implement a custom error page, what i want to be able
I'm making a custom error dialog in my WPF app and I want to
I got this an asp.net 3.5 page that and I have few tabs (telerik
okay, so i have an asp.net (C#) application and i want to add a
My base controller has this override: protected override void OnException(ExceptionContext filterContext) { // http://forums.asp.net/t/1318736.aspx

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.