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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:09:11+00:00 2026-06-02T15:09:11+00:00

In my asp.net mvc 3 application I’ve done some error handling and I happy

  • 0

In my asp.net mvc 3 application I’ve done some error handling and I happy it working. It works properly on the local computer. But on the hosting the iis perhaps substitute errors views by its own error pages. I think and I’m almost sure it’s because of Response.TrySkipIisCustomErrors.

But I set Response.TrySkipIisCustomErrors to true; and there’s no effect.

web.config

<customErrors mode="Off"></customErrors>

Global.asax

void Application_Error(object sender, EventArgs e)
 {
   var exception = Server.GetLastError();
   Response.Clear();
   Server.ClearError();
   Response.StatusCode = (int)HttpStatusCode.InternalServerError;
   Response.TrySkipIisCustomErrors = true;

   var routeData = new RouteData();
   routeData.Values["controller"] = "Errors";
   routeData.Values["action"] = "ServerError";

   var httpException = exception as HttpException;
   if (httpException != null)
    {
       Response.StatusCode = httpException.GetHttpCode();
       switch (Response.StatusCode)
        {
          case 403:
            routeData.Values["action"] = "Unathorized";
                       break;
          case 404:
            routeData.Values["action"] = "NotFound";
                        break;
                }
       }

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

How rewrite this code to get IIS on the hosting handle errros as I want.

  • 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-02T15:09:15+00:00Added an answer on June 2, 2026 at 3:09 pm

    Try to derive from a controller base class, which will override the OnException method, and put all your error handling code there.

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

Sidebar

Related Questions

I am working on asp.net MVC application. I have a folder with some sub
I have an Asp.Net MVC application that works in the vs.net development web server.
when I build Asp.net MVC Application in TFS Server. I am getting this error
I have an ASP.NET MVC application, with some RESTful services that I'm trying to
I have created a Asp.net MVC application. Now required 404 handling. Have updated global.asax
I am developing ASP.NET MVC application. I made some changes to save some extra
I upgraded a large ASP.NET MVC application I've been working on to the latest
I have an asp.net mvc application that works fine under visual studio but when
My ASP.NET MVC application fails with this error: BC30456: 'Title' is not a member
I am creating an ASP.NET MVC application that has postcode lookup functionality. I capture

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.