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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:33:06+00:00 2026-06-19T00:33:06+00:00

I am working on Asp.net mvc3 application.For exception handling i using following code in

  • 0

I am working on Asp.net mvc3 application.For exception handling i using following code in global.asax

    protected void Application_Error(object sender, EventArgs e)
    {
        Exception exception = Server.GetLastError();
        Response.Clear();
        HttpException httpException = exception as HttpException;
        Server.ClearError();
        Response.Redirect("/Secure/Error", false);
    }

if any exception occur it will redirect to Error page.I want to some exeception should not redirect to Error page.

Like if any user enter following url

http://www.example.com/index

there is no controller of ‘index‘ name it will be throw exception

The controller for path ‘/index’ was not found or does not implement
IController

I want this when this exeception occur it should redirect to http://www.example.com

How can i do this?

There are some other keyword like index.. that should be redirect to main url of website

  • 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-19T00:33:07+00:00Added an answer on June 19, 2026 at 12:33 am

    If you want to do that only for specific keywords, why not add corresponding routes instead of handling the 404 – Not Found exceptions?

    You could do this in your Globals.asax.cs file, next to the other route definitions:

    routes.MapRoute(
        "IndexRoute", // Route name
        "index", // URL 
        new { controller = "Home", action = "RedirectToRoot" }
        );
    

    and likewise for all keywords other than index.

    Update

    After making /index and the other urls point to HomeController.RedirectToRoot() (or another controller/action of your choice), just implement it to return a RedirectResult that would take the user to the site’s root:

    public RedirectResult RedirectToRoot()
    {
        return RedirectToAction("Index", "Home");
    }
    

    Update 2

    If you are absolutely sure that you’ll never use /index or the other special urls for anything but redirecting to root, then you could do a permanent redirect instead:

    return RedirectToActionPermanent("Index", "Home");
    

    This will save some round trips to the server, but the redirection will be permanently stored in client browsers, making it very hard/impossible to use those urls for anything else in the future.

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

Sidebar

Related Questions

I'm working on a web application project using ASP.NET MVC3 and database in SQL
I'm working on an Asp.Net MVC3 application, using jQuery. On a specific page, the
I have been working on ASP.net MVC3 Web application using MSSQL 2008 R2 for
I am working on an ASP.NET MVC3 application. In the Views I created a
I'm working on ASP.net MVC3 Web application that is facing scalability issue. For improving
I'm working on Asp.net MVC3 web application. I'm having one page on which appx.
I'm working on a ASP.NET MVC3 web application and I want to create a
I am working on ASP.NET 4.0 MVC3 web application that works in intranet environment.
I am working on a web application (asp.net mvc3) I have a Main div.
I have the following WebGrid in my ASP.NET MVC3 test application. It displays a

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.