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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:48:00+00:00 2026-06-07T21:48:00+00:00

Is there a way to populate a Dynamic object with Query String parameters? This

  • 0

Is there a way to populate a Dynamic object with Query String parameters?

This is so that my search parameters in the QS can vary without binding them directly to a container object or having to change the signature of the search method.

e.g.

Inbound URL: http://www.test.com/Home/Search?name=john&product=car&type=open&type=all

public ActionResult Search()
{
    dynamic searchParams = // **something magic here**

    var model = getResults(searchParams);
    return View(model);
}

The populated searchParams object should look like:

{
    name = "john",
    product = "car",
    type = { "open", "all" }
}

Any ideas?

  • 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-07T21:48:03+00:00Added an answer on June 7, 2026 at 9:48 pm

    One solution can be that you build up an ExpandoObject from the Request.QueryString which is a NameValueCollection.

    It’s easy to write the transformation and you can put it inside an extension method:

    public static class NameValueCollectionExtensions:
    {
        public static dynamic ToExpando(this NameValueCollection valueCollection)
        {
            var result = new ExpandoObject() as IDictionary<string, object>;
            foreach (var key in valueCollection.AllKeys)
            {
                result.Add(key, valueCollection[key]);
            }
            return result;
        }
    }
    

    And in your controller you can use like:

    public ActionResult Search()
    {
        dynamic searchParams = Request.QueryString.ToExpando();
    
        DoSomething(searchParams.name);  
        var model = getResults(searchParams);
        return View(model);
    }
    

    Note: You will need to do some additional transformation to handle to type property which won’t be automatically an array by default.

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

Sidebar

Related Questions

Is there way that I can read the file from remote server using fopen
Is there a way to populate the Silverlight toolkit's WrapPanel via binding to an
Is there a way to safely populate a byte array from multiple threads (e.g.
For a simple plot below, is there a way to make matplotlib populate the
Is there way to set @include mixin(); to variable? I tried this @mixin bg-gradient($fallback,
Is there any way to have a listbox populated by both static and dynamic
I have a WebMethod that looks like this which is used to populate a
in AS3, I'm making this dynamic textfield that is populated from an XML file
Is there any way to populate TCP-H database for Microsoft SQL Server 2008. TPC-H
I just started developing on Oracle. Is there a way to populate data in

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.