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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:52:59+00:00 2026-06-03T09:52:59+00:00

Why doesn’t this work? Route: routes.MapRoute( Summary, {controller}/{id}, new { controller = Summary, action

  • 0

Why doesn’t this work?

Route:

routes.MapRoute(
                "Summary",
                "{controller}/{id}",
                new { controller = "Summary", action = "Default" }
            );

Controller:

public class SummaryController : Controller
    {
        public ActionResult Default(int id)
        {
            Summary summary = GetSummaryById(id);

            return View("Summary", summary);
        }
    }

URL:

http://localhost:40353/Summary/107

Error:

Server Error in '/' Application.

    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

    Requested URL: /Summary/107

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225

Update:

Let me update the question with a more intelligent one. How can I have both of these?

routes.MapRoute(
                    "Home",
                    "{controller}",
                    new { controller = "Home", action = "Default" }
                );

routes.MapRoute(
                    "Summary",
                    "{controller}/{id}",
                    new { controller = "Summary", action = "Default" }
                );
  • 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-03T09:53:01+00:00Added an answer on June 3, 2026 at 9:53 am

    How do routes work (by default)?

    Let’s get back to the default route, which is somewhat like this one:

    routes.MapRoute(
    
        // Route name
        "Default", 
    
        // URL with parameters
        "{controller}/{action}/{id}", 
    
        // Parameter defaults
        new { controller = "Home", action = "Index", id = UrlParameter.Optional } 
    
    );
    

    Let’s try to understand how this one works.

    • If you access /, it will call the Index action of the Home controller; the optional Id was ommitted.

    • If you access /C it will call the Index action of the C controller; the optional Id was ommitted.

    • If you access /C/A it will call the A action of the C controller; the optional Id was ommitted.

    • If you access /C/A/1 it will call the A action of the C controller with id 1.

    So, that route allows any URLs of the form /, /C, /C/A and /C/A/1 where C is a controller and A is an action. What does this mean? This means that you don’t necessarily have to specify your own routes.

    So, without routes you could just have a HomeController and a SummaryController and add an action to that last controller called Show.

    Then /Summary/Show/1 would call SummaryController.Show(1)


    What if I want to have a shorter route (/Controller/Id) for a controller?

    Let’s suppose we do want to map routes such that /Summary/1 calls SummaryController.Show(1).

    Here is the correct form:

    routes.MapRoute(
        "Summary",
        "Summary/{id}",
        new { controller = "Summary", action = "Show" }
    );
    
    routes.MapRoute(
        "Default",
        "{controller}/{action}/{id}",
        new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );
    

    Note that we have changed the Home route to look like the Default route. Now we’ve added a Summary route where we tell that URLs of the form Summary/{id} will trigger that route. When they do, it calls the Show action of the Summary controller and pass along id as a parameter; which is exactly what you want…

    Also note that we need to place the Summary route first such that it gets precedence.

    Caution: You will not want to create a new route for every single action you create. You also don’t want all your actions to be in the same controller. Consider rethinking your approach if one of these is the case, so that you don’t end up with problems later…

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

Sidebar

Related Questions

Why doesn't this work? HTML <div class=gallery> <div class=viewport> <div class=wrapper> <img src=img/boat1.png />
Why doesn't this work as one may have naively expected? class Foo(object): def __init__(self):
Why doesn't this work: <Style TargetType=s:Substance> <Setter Property=Template> <Setter.Value> <DataTemplate> <StackPanel> <TextBlock Text={TemplateBinding Name}/>
This doesn't work: $to = 'myemail@gmail.com'; $from = 'test@test.com'; $subj = 'test'; $message =
Why doesn't this code work? I'am using FF. <head> <script type=text/javascript> document.getElementById(someID).onclick = function(){
Why doesn't this work? type RetryBuilder(max) = member x.Return(a) = a // Enable 'return'
Why doesn't this work? Can Anyone tell me whats wrong with this onitemclicklistener? It
This doesn't work, but it shows you what I want to do: $(this+:after).css('content', 'something');
Why doesn't this work? I have bypassed this before but i can't remember how
Why doesn't Html.ActionLink work in the below code? This is a page in 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.