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

The Archive Base Latest Questions

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

I am working through a new project using Knockout.js and the ASP.NET web ApiController.

  • 0

I am working through a new project using Knockout.js and the ASP.NET web ApiController. Many of the examples I see perform some manual JSON serialization before posting the data to the server. Additionally, the request content type is equally often set to “application/json”.

I am wondering why this is necessary. I’m assuming there’s something I haven’t yet encountered that makes this either required or at least preferable.

Currently, I am having no issues sending any data I desire to the server using these jQuery ajax options:

        cache: false,
        traditional: true,
        type: 'POST',

Here’s sample JS object and corresponding server-side C# model object that POSTs and binds to the ApiController action method just fine.

//JS object
var requestDataObject = {
    accountId: vm.accountId,
    range: [1, "a'b\"c", 3],
    start: new Date(2012, 12, 12)
};

//C# model object
public class RequestData
{
    public int AccountId { get; set; }
    public string[] Range { get; set; }
    public DateTime Start { get; set; }
}

//Action method signature
[HttpPost]
public HttpResponseMessage GetAccountUsage(RequestData requestData){
    ...

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-06-16T06:33:41+00:00Added an answer on June 16, 2026 at 6:33 am

    Historically, GET (and subsequently POST) can only send key-value pairs, and the keys should be unique.

    When PHP came, it defined “if a key contains square brackets, let’s build an array”. This enabled the programmers to call their checkboxes name="chkbox[]", let the form submit normally, and read $_POST['chkbox'] as an array. Some other server languages defined, “if a key is repeated in the query string, let’s build an array”.

    If the key names[]=1 was to be supported, why not names[a][b][c]=1? The servers knew what they should do: Assign names = {a:{b:{c:"1"}}}.

    This enables the programmers to encode objects to query the string, with a few catches:

    • Every value is a string
    • There is no distinction between arrays and objects with numeric keys. PHP doesn’t care, but some servers might.
    • There is no way to encode empty objects or arrays. With traditional forms, this results in empty arrays missing. PHP does care. JQuery solves that by sending an empty string instead.
    • It’s extremely inefficient as the path has to be repeated for each value: checkboxes[]=ch1&checkboxes[]=ch2&... vs. checkboxes=["ch1","ch2",...]
    • you have to know the target platform as PHP doesn’t like traditional (or resort to reading from postVars.get("names[]") on servers that do)
    • some servers don’t understand this encoding at all.

    With JSON,

    • you can encode numbers, strings, null, …
    • … arrays, objects…
    • empty arrays and objects are easy to represent. You don’t have to test the presence of each array and object just because it might be empty.
    • no key is ever repeated, so you don’t need to keep your keys short
    • there is no confusion how to represent an array with automatic keys; a JSON encodes the same structure no matter where it’s sent.
    • Parsing JSON is possible in any language. Lot of languages have JSON support built in, the rest can fetch a library.
    • you only have to write one extra line on the server and the client.

    In short, if you only need to encode key-value pairs, that’s what a plain GET or POST excels at. If you need to encode arrays, JSON is definitely worth considering. If you need anything more complex, JSON is the only way to go with some servers.

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

Sidebar

Related Questions

I am working through the book Professional ASP.NET MVC 2 and I am trying
I'm currently working on some project, using Apache Tapestry 5.3.6. I have issue using
I am working on a web application project using Tapestry 5 framework/javascript. This application
I've been working on a simple project that uses some common .NET classes, isolated
I'm working through the SportsStore example from Pro ASP.NET MVC 3 Framework . At
You may have heard of a website called Project Euler (projecteuler.net). I'm working through
I have been working my way through Scott Guthrie's excellent post on ASP.NET MVC
I am new to Backbone and started by working through the Todos example. After
Disclaimer, new to programming, working my way through C++ Prime Plus 6th ed. I'm
So, I'm quite new to Rails and still working my way through the principles.

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.