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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:19:40+00:00 2026-06-16T05:19:40+00:00

Are these two pieces of codes the same? RouteValueDictionary dic=new RouteValueDictionary(); dic.Add(controller, Home); dic.Add(action,

  • 0

Are these two pieces of codes the same?

RouteValueDictionary dic=new RouteValueDictionary();
dic.Add("controller", "Home");
dic.Add("action", "Index");
RouteTable.Routes.MapRoute("Test", "Test/Something", dic);

and

 RouteTable.Routes.MapRoute("Test", "Test/Something", new{controller="Home", action="Index"});

I am not getting the same route in the route table. When I use the first option, the keys “controller” and “action” arent in RouteTable.Routes[0].Defaults.Keys but are added on the RouteTable.Routes[0].Defaults.Values

Do you know what I am doing wrong in the first option?

  • 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-16T05:19:42+00:00Added an answer on June 16, 2026 at 5:19 am

    you can pass object of any type for third parameter but the passed object must have included keys defined in you’r url pattern as it’s properties.for example

     public class test
        {
            public string controller { get; set; }
            public string action { get; set; }
            public string id { get; set; }
        } 
    
         routes.MapRoute(
                "Default",
                "{controller}/{action}/{id}", 
                 new test { action = "Index", controller = "Home", id = "" } 
            );
    

    in this case you’r object must include controller,action,id properties.

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

Sidebar

Related Questions

Why these two pieces of codes, running on same conditions, does not have difference
How do these two pieces of code differ when accessing a REST API? $result
These two methods appear to behave the same to me public IEnumerable<string> GetNothing() {
These two querys gives me the exact same result: select * from topics where
So these two methods have the same signature but different constraints public static void
Do these two statements pass the same type of argument (a Hash) to the
I have these two pieces of code. The first one works perfectly: UIView *tmp
My question is are the following two pieces of code run the same by
What is the difference between these two pieces of code? class something { static
I have these two pieces of code that could possibly be run at 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.