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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:31:22+00:00 2026-05-23T09:31:22+00:00

I set custom error enable in Web.config: <customErrors mode=On/> and, in Application_Start, put these:

  • 0

I set custom error enable in Web.config:

<customErrors mode="On"/>

and, in Application_Start, put these:

protected void Application_Error(object sender, EventArgs e) {

    var ex = Server.GetLastError().GetBaseException();

    var routeData = new RouteData();

    if (ex.GetType() == typeof(HttpException)) {
        var httpException = (HttpException)ex;
        var code = httpException.GetHttpCode();
        routeData.Values.Add("status", code);
    } else {
        routeData.Values.Add("status", -1);
    }

    routeData.Values.Add("action", "Index");
    routeData.Values.Add("controller", "Error");
    routeData.Values.Add("error", ex);

    IController errorController = new Kavand.Web.Controllers.ErrorController();
    errorController.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
}

also I create an error controller like this:

public class ErrorController : Kavand.Web.Mvc.Kontroller
{
    public ActionResult  Index(int status, Exception error) {
        Response.StatusCode = status;
        HttpStatusCode statuscode = (HttpStatusCode)status;
        return View(statuscode);
    }
}

but, when an error occurred, the yellow-page shown, instead of my custom view! can everybody help me please?!
Thanks a lot, 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-23T09:31:22+00:00Added an answer on May 23, 2026 at 9:31 am

    Don’t forget to clear the error in Application_Error after fetching it:

    protected void Application_Error(object sender, EventArgs e)
    {
        var ex = Server.GetLastError().GetBaseException();
        Server.ClearError(); // <-- that's what you are missing
        var routeData = new RouteData();
        ...
    }
    

    Also it is important to remove the HandleErrorAttribute global attribute which is added in the RegisterGlobalFilters static method in Global.asax as you no longer need it.

    You may also find the following answer useful.

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

Sidebar

Related Questions

I've got customErrors set in my web.config <customErrors mode=On defaultRedirect=/Error/GeneralError> <error statusCode=404 redirect=/Error/NotFound/> </customErrors>
I have a custom error page set up for my application: <customErrors mode=On defaultRedirect=~/errors/GeneralError.aspx
I have custom errors enabled in my web.config file: <customErrors mode=On defaultRedirect=~/ErrorPage.aspx /> When
Here's the situation: - I have <customErrors mode=On defaultRedirect=error.html /> in my web.config. I
On my web application, I had configured my web.config file to set customerrors to
I'm building a web app and want to enable logging/error tracking. After reading the
I am trying to set custom error messages for invalid length of the following
I am trying to add custom error pages to my web application. So far
Having a weird problem here. Everybody knows that if you use web.config's customErrors section
Has anyone managed to get a custom IMessageInterpolator working to enable customisation of error

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.