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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:41:14+00:00 2026-05-29T08:41:14+00:00

This has probably been asked already – if so sorry! I couldn’t find it.

  • 0

This has probably been asked already – if so sorry! I couldn’t find it.
I am unsure as to how asp is able to decide when to use a query string and “normal looking paths” (Embedded values)
Take this for example:

routes.MapRoute(

    "SomePage",
    "Net/Fix/{value}",
    new { controller = "Net", action = "Index" }
    );

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

I don’t know how to explain – I will try.. If I am wrong please explain it

Question 1.
Is the first argument in mapRoute so that we can specify which routing we want to take place when using hyperlinks?

Question 2.
What does the second argument do?
It appears as if the second argument gives you the option of specifying how the routing should occur as below: “Net/Fix/hello” or by specifying placeholders in the form of {controller}/{action}/{somevar}

Question 3:
I assume if nothing is used in question 2 scenario – this specifies default routing that should take place?

Question 4:
How does ASP.NET infer whether to use a query string or an embedded value..

Because for example when I decide to call my page

http:/localhost:portno/Net/Fix/hello

It dutifully prints hello.. but when I do this

http:/localhost:portno/Net/Index/hello

It doesn’t work.. unless I do

http:/localhost:portno/Net/Index?value=hello..

Question is… why?!!!

I hope questions were clear.. I will reply to answers (if any later).

  • 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-29T08:41:14+00:00Added an answer on May 29, 2026 at 8:41 am

    The first argument is a route name. Each route should have a unique name, and they can be used for creating links, to assure a link is based on a certain route. It’s not important in your case of matching a route.

    The second argument is a matching pattern. Literal values are shown in clear, and parameterized values inside curly braces. {}. The parameterized values are not just for specifying the location of a parameter, but also the name of it.

    I’m not sure offhand why you would define a route without any matching pattern. Does such an overload of MapRoute() exist?

    The reason you get the behavior you do with this url: http:/localhost:portno/Net/Index?value=hello It matches the second (the default) route, not the first.

    However, look at the second route pattern:

    "{controller}/{action}/{id}"
    

    The controller is the first parameter, action is the second. So with your URL, that request is routed to the Net controller, Index action. the same as your first example.

    Because the query string contains a value parameter, that still gets passed to the action method. And it just so happens your action method has a string parameter named value, so it works.

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

Sidebar

Related Questions

This probably has probably been asked before, but I couldn't find anything relevant. Would
This has probably been asked before, but I couldn't find it. Is there a
This has probably been asked before but I couldn't find the answer to my
This has probably been asked before on SO, but I was unable to find
This has probably been asked before, but I can't find a good way of
I know this has probably been asked before, but I can't find it with
I feel like this question has probably been asked a thousand times already, so
I know this question has probably been asked already but I would really like
This has probably been asked before but I can't find any relevant post using
This has probably been asked, but I can't find it... I want to link

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.