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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:03:35+00:00 2026-05-25T10:03:35+00:00

My goal is to remove home from any actions in that controller (see bold).

  • 0

My goal is to remove “home” from any actions in that controller (see bold).

site.com/home/about
site.com/about

site.com/home/contact
site.com/contact

I created the following custom route that sits above the generic base route:

// Used to hide 'home' in the url
routes.MapRoute(
            "Home", // Route name
            "{action}", // URL with parameters
            new { controller = "home", action= "index"} // Parameter defaults
);

This almost does what I want. I now get site.com/about, site.com/contact, etc. However, I cannot use index for my other controllers.

site.com/person/create -> works like a charm.
site.com/person/ -> no good.

How can I fix this? Thanks.

  • 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-25T10:03:36+00:00Added an answer on May 25, 2026 at 10:03 am

    These two routes should work as expected:

    routes.MapRoute(
       "NoHomeRoute", // Route name
       "{controller}/{action}", // URL with parameters
       new { controller = "Person", action= "Index"}, // Parameter defaults
       new { controller = @"person|admin|..." } // Parameter constraints
    );
    routes.MapRoute(
       "HomeRoute", // Route name
       "{action}", // URL with parameters
       new { controller = "home", action= "index"} // Parameter defaults
    );
    

    Since every application has a predefined set of controllers you can put all except home in the upper constraint and it will work. But if you create a new controller, remember to put it in as well. I’ve put in person for PersonController which you obviously have and also added admin for AdminController you probably don’t have, but I needed to put in something to show you the pattern of adding your controllers.

    If you’re willing to play around with regular expressions, then you could maybe come up with a solution that excludes home instead of includes all except home the way that upper route definitions suggest.

    A revised negative constraint

    I’ve checked MVC code and indeed you can define a future proof constraint on the first route definition this way:

    routes.MapRoute(
       "NoHomeRoute", // Route name
       "{controller}/{action}", // URL with parameters
       new { controller = "Person", action= "Index"}, // Parameter defaults
       new { controller = @"(?!home).*" } // Parameter constraints
    );
    

    Why should this work? Because the line on ProcessConstraint method has these two lines at the end:

    string pattern = "^(" + str + ")$";
    return Regex.IsMatch(input, pattern, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My goal is to remove from the raw stack the records that are not
My goal is to remove IE conditional comments from my documents' <head> , but
Goal: Produce an Excel document with information from 3 associated models that is similar
My goal is to remove all <[script]> nodes from a document fragment (leaving the
Basically, my goal is to remove everything inside ()'s except for strings that are
My goal is to remove all hover feedback from the UI. The motivation is
This is the goal: to remove Navigation Bar in some of the editors (no
Goal is to make a dialog that appears on menu_key pressed, but it keeps
My goal is to take HTML entered by an end user, remove certain unsafe
How can you remove the favicon using Javascript in google chrome? The goal is

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.