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

  • Home
  • SEARCH
  • 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 849937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:10:59+00:00 2026-05-15T07:10:59+00:00

I have multiple controllers with different actions (no Index actions). The actions I consider

  • 0

I have multiple controllers with different actions (no “Index” actions). The actions I consider “default” actions, are named differently. I want to create default routes for their names and have the first available action (from my list of default actions) executed if only the controller name is provided in the route.

So, for example, I have the following actions which I want to consider default and want checked for their existence in a controller in this order:

List() 
Draw()
ViewSingle() 

The routing should somehow search for /{controller} and then take the first available action from the list above as default action, e.g.:

/ControllerA     -> ControllerA.List()
/ControllerB     -> ControllerB.Draw()
/ControllerC     -> ControllerC.ViewSingle()
/ControllerD     -> ControllerD.Draw()
/ControllerE     -> ControllerE.List()

Is this possible? I tried creating additional Default actions like this but couldn’t get it to work:

routes.MapRoute("Default1", "{controller}/{action}", 
 new { controller = UrlParameter.Optional, action = "List" } 

routes.MapRoute("Default2", "{controller}/{action}", 
 new { controller = UrlParameter.Optional, action = "Draw" } 

routes.MapRoute("Default3", "{controller}/{action}", 
 new { controller = UrlParameter.Optional, action = "ViewSingle" } 

Help?

  • 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-15T07:11:00+00:00Added an answer on May 15, 2026 at 7:11 am

    I think you got something wrong about the default route. Those controller and action parameters are there for convention. If URL has a controller name in it, it will route to suitable controller. Same thing is true for Index methods. It just provides a default value for that.They are already optional and that’s why. I think you don’t need routes here: You could try to place your default functions in Index methods and it would work.Just to be clear:

    public class ControllerA:Controller
    {
        public ActionResult Index()
        {
            return List();
        }
    
        public ActionResult List()
        {
        //List function
        }
    }
    
    
    public class ControllerB:Controller
    {
        public ActionResult Index()
        {
            return Draw();
        }
    
        public ActionResult Draw()
        {
        //Draw function
        }
    }
    

    I think it would work. But if you want to go on with creating routes, you create each route like this:

    routes.MapRoute("Default1", "ControllerA", 
     new { controller = ControllerA, action = "List" }
    

    Notice that ControllerA is not in curly braces,it’s a static text. So you create routes for each controller. Keep controller naming convention in mind.

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

Sidebar

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.