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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:40:09+00:00 2026-05-11T18:40:09+00:00

I seem to have a problem with getting MVC to fill in my custom

  • 0

I seem to have a problem with getting MVC to fill in my custom model parameter when called through GET instead of POST.

I have a JavaScript snippet that calls into an action like so:

$.getJSON('<%= Url.Action("DoSearch") %>' + location.search,
    function(data) {
        if (data.Result == "OK") {
            location.href = location.href;
        }
    });

What it does, is basically call a separate action, passing it the same querystrings as the calling page. Then if the result is “OK”, it refreshes the current page.

The action is defined like the following:

    public ActionResult DoSearch(SearchParameters searchParameters)

The model is:

public class SearchParameters
{
    public string Query;
    ...
}

Calling URL (verified with firebug) is like /DoSearch?Query=some+query. (also tried /DoSearch?searchParameters.Query=some+query with no success)

No matter what I tried, my parameter always comes up as empty (not null, just all of the parameters being initialized to their default values)

If I define the action like this instead:

    public ActionResult DoSearch(string Query, ...)

Then my parameters get filled correctly. Not with the model however.

I assume:

a) either populating the object model doesn’t work for GET requests.

b) I’m doing something wrong

Any ideas? Thanks.

  • 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-11T18:40:09+00:00Added an answer on May 11, 2026 at 6:40 pm

    You need public properties to bind on a class.

    replace

    public string Query;
    

    with

    public string Query{get;set;}
    

    At least that’s what I had to do to get it to work in my project.. I don’t know if you have another problem as well.
    Oh and I used GET as well so it should work.

    This is my Parameters class:

    public class Parameters
    {
        public int? page { get; set; }
        public int? pageSize { get; set; }
        public string[] columnsToDisplay { get; set; }
        public string columnToSort { get; set; }
        public bool? descending { get; set; }
    }
    

    Didn’t bind with fields.

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

Sidebar

Related Questions

No related questions found

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.