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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:28:26+00:00 2026-05-13T17:28:26+00:00

I am trying to send the route values to a method but I cant

  • 0

I am trying to send the route values to a method but I cant seem to figure this out. Here is my code

<%  string s = "cool";
    object d = new {  s = "1" };

         %>
<%= Html.ActionLink("Home", "Index", d, "ql")%>

The following code produces a url like this

http://localhost:49450/?s=1

the url should be like this

http://localhost:49450/?cool=1

What am I missing

  • 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-13T17:28:26+00:00Added an answer on May 13, 2026 at 5:28 pm

    because in the context of a ‘new { … }’ expression the ‘s’ does not correspond to a variable as it may first appear – it defines the name of a member of an anonymous class that is created.

    when you say :

    new { S = 123 }

    you are actually generating a class, which is anonymous (you never get to see the name of the class). The type of each member of the class is implicitly determined by whatever you’re assigning to it. In the above example a class something like this is generated

    class AnonymousClass_S483Ks4 {
     public int S {get;set;}
    }
    

    There are two ways you can do what you want:

    1) you would have to say :

    new { cool = 123 } 
    

    2)
    Now I assume though that you want the name to be dynamic so you need to use RouteValueDictionary which allows you to put key value pairs in.

            // RouteValueDictionary is IDictionary<string, object>
            var dictionary = new RouteValueDictionary();  
            string s = "cool";
            dictionary.Add(s, 123);
            htmlHelper.ActionLink("Home", "Index", dictionary);
    

    As you can see, here you can use a variable ‘s’ to represent whatever you want. This should give you the URL you need.

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

Sidebar

Related Questions

I'm trying to send an email in Java but when I read the body
I am trying to send an email from a site I am building, but
I'm trying to figure out a nice way to limit the rate at which
This question sort of covers both ServerFault.com and here, but this seems more programming
Trying to send array + vars with Ajax, Sending just the array worked fine...but
im trying to send a Windows message to my Delphi application, but im having
I am trying to send my dynamically created silverlight 2 page/image to a an
I'm trying to send the output to the console (or colouredconsole) ... which I'm
I'm trying to send email to Active Directory distribution groups. I know you can
i'm trying to send fake keyboard input to an application that's running in a

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.