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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:38:52+00:00 2026-05-12T05:38:52+00:00

I am trying to make a rest service that receives complex types from a

  • 0

I am trying to make a rest service that receives complex types from a Jquery $.ajax post but I cannot seem to convince mvc to hydrate my complex objects in the controller.

The following is some of my code:

Controller:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ChargeUser(TransactionInfo transactionInfo, CardInfo cardInfo) {
/// both transactionInfo and cardInfo are un-populated.   
}

DTOs:

[Serializable] public class CardInfo : ICardInfo {
        public string CCNumber { get; set; }
        public int ExpirationMonth { get; set; }
        public int ExpirationYear { get; set; }
        public string CardVerificationValue { get; set; }
}

[Serializable]
public class TransactionInfo : ITransactionInfo
{
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Address1 { get; set; }
        public string Address2 { get; set; }
        public string City { get; set; }
        public string Region { get; set; }
        public string Country { get; set; }
        public string PostalCode { get; set; }
        public string Currency { get; set; }
        public decimal Amount { get; set; }
}

Sample JSON that I am POSTing, looks like this:

"{"transactionInfo":{"FirstName":"Hal","LastName":"Lesesne","Address1":"504 Anytown Drive","Address2":"Sample Address 2","City":"Boone","Region":"NC","Country":"US","PostalCode":"28607","Currency":"USD","Amount":"1.5"},"cardInfo":{"CCNumber":"4222 2222 2222 2222","ExpirationMonth":"1","ExpirationYear":"2009","CardVerificationValue":"333"}}"

Using a jquery call like this:

function jQueryPost(data, action, onSuccess, onFailure) {
    $.ajax({ 
        url: action,
        type: 'POST',
        data: data,
        dataType: 'json',
        contentType: "application/json; charset=utf-8",
        error: onFailure,
        success: onSuccess
    });    
}

I hit the break point when debugging, but neither transactionInfo nor cardInfo are populated and have only default values for stings (null) and numerics (0).

I assume that I am doing something wrong with my json formatting, but simply cannot figure it out. Any insight would be greatly appreciated.

Best regards and thank you for your time.

Hal

  • 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-12T05:38:52+00:00Added an answer on May 12, 2026 at 5:38 am

    I think the way the model binder is expecting the query string to look would be more like:

    TransactionInfo.FirstName=Hal&TransactionInfo.LastName=Lesesne&...
    

    If your object is like:

    { "TransactionInfo.FirstName" : "Hal", "TransactionInfo.LastName", "Lesesne", ... }
    

    Then I think it will correctly serialize it into the query string that MVC expects.

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

Sidebar

Related Questions

I am trying to make a simple REST Service with .NET 4.0 that uses
So I'm trying to create a C# WCF REST service that is called by
I'm trying to get the sample code from Mozilla that consumes a REST web
I am trying to make it stop showing the rest if $walk_jail is not
Trying to make a make generic select control that I can dynamically add elements
Trying to make a custom :confirm message for a rails form that returns data
I am trying to make a WCF REST method entirely asynchronous (I don't want
I am currently trying to create a REST proxy that calls a WCF SOAP
I'm trying to make this blue line (a div) automatically fill the rest of
I'm trying my hand at making a rest full ruby service. The way my

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.