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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:01:25+00:00 2026-06-06T15:01:25+00:00

I’m getting what I consider to be a weird binding issue in the ASP.NET

  • 0

I’m getting what I consider to be a weird binding issue in the ASP.NET MVC 4 RC Web API. I have a method intended to accept post requests from the client. The issue is that none of the parameters are binding when the post method is called, I get to my break point on the throw line and name, email are both null. If I change the type of the request to GET in the JavaScript, then the Get function below is called with parameters bound.

Why are the parameters failing to bind for the Post method, and how can I fix this?

send: function(evt) {
    evt.preventDefault();
    $.ajax( {
        url: '/api/person',
        data: this.model.toJSON(),
        type: "POST",
        dataType: "json",
        success: function(data) {
            console.log("Success");
        },
        error: function(data) {
            console.log("Error");
        }
    });
     }

The following is the controller actions:

public void Get(string name, string email) {
    throw new NotImplementedException();
}

public void Post(string name, string email) {
    throw new NotImplementedException();
}

Notes:

  • I’m using all of the defaults for ASP.NET MVC 4 RC Web API (So the deserializer should be Json.NET)
  • The Chrome network tab on the JS debugger shows the parameters in the form data on post correctly.
  • 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-06T15:01:27+00:00Added an answer on June 6, 2026 at 3:01 pm

    Unlike MVC (web pages), simple parameters types will not, by default, bind from the post body but instead from the URI. So, with your code as-is you would need to pass the name and email parameters in the query string or as route parameters.

    However this can easily be solved by creating a model type (in MVC vernacular) and using that for the method parameters. In fact you can then use it for both (in the case that you’ve given), if you then use [FromUri] on the get method:

    public class SomeParams {
      public string name { get; set; }
      public string email { get; set; }
    }
    
    //now an alternative way to write the Get method
    public MyResult Get([FromUri] SomeParams p){
      //members are bound from the query string (more like MVC traditional binding)
      //note - as in MVC, SomeParams will need a default constructor for this to work.
    }
    
    public PostResult Post(SomeParams p){
      //'p' is bound from your JSON (assuming correct format)
      //because 'complex' types are deserialized using formatters
      //only one object can be read from the body with a formatter in Web API
      //as the request body is not buffered; unlike MVC.
    }
    

    I’ve stuck in return types for the methods just because they would need to return something!

    I really do recommend reading through Mike Stall’s article that I link to above (and many of his others).

    It’s tempting to assume that the Web API, because it shares the same paradigms and even class names of MVC, is actually the same as MVC – but it’s not. I wondered initially why this was the case (as I’ve written a lot of REST services on top of MVC myself and found it to be pretty darn cool, once you’ve written a few utility classes and base-class enhancements), but they’ve taken a proper look at the challenges of writing a web API and I think are probably right to have made the changes in approach that they have.

    However, it does mean that we have to take a few things we might now take for granted and re-learn them for the Web API.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.