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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:12:32+00:00 2026-05-16T15:12:32+00:00

Following on from this question: ASP.NET MVC Routing with Default Controller I have a

  • 0

Following on from this question:

ASP.NET MVC Routing with Default Controller

I have a similar requirement where my end user doesn’t want to see the controller name in the url for the landing or “home page” for their application.

I have a controller called DeviceController which I want to be the “home page” controller. This controller has a number of actions and I’d like to use URL’s like the following:

http://example.com  -> calls Index()  
http://example.com/showdevice/1234 -> calls ShowDevice(int id)  
http://example.com/showhistory/1224 -> calls ShowHistory(int id)  

I also need links generated for this controller to leave out the /device part of the url.

I also have a number of other controllers, for example BuildController:

http://example.com/build  
http://example.com/build/status/1234  
http://example.com/build/restart/1234  

and so on. The URL’s for these controllers are fine as they are.

The problem is that I just can’t seem to get my head around the routing for this even after studying the answers to the question referenced above.

Can someone provide a code sample explaining how to do this?

I’m using ASP.NET MVC2.

  • 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-16T15:12:33+00:00Added an answer on May 16, 2026 at 3:12 pm

    Try this:

       private void RegisterRoutes(RouteCollection routes) {
    
          routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
          routes.MapRoute("default", "{controller}/{action}/{id}",
             new { action = "index", id = "" },
             // Register below the name of all the other controllers
             new { controller = @"^(account|support)$" });
    
          routes.MapRoute("home", "{action}",
             new { controller = "device", action = "index" });
       }
    

    e.g. /foo

    If foo is not a controller then it’s treated as an action of the device controller.

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

Sidebar

Related Questions

This question is being based off of a similar question titled, ASP.NET MVC Relative
Following on from my earlier question around loading views from DLLs under ASP.NET MVC,
Following on from my previous question, If I am beginning to learn asp.net MVC,
On ASP.NET MVC 3, assume that we have following controller action: public ActionResult Index()
Following on from this question...I'm trying to unit test the following scenario: I have
For the web application (ASP.NET MVC) I'm currently developing, we have the following architecture
I have an Action method in an ASP.NET MVC Controller class that handles form
Following on from this question , I am interested in finding out how you
following on from this question (Developing to an interface with TDD), I'm still having
Following on from this question... What to do when you’ve really screwed up the

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.