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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:43:55+00:00 2026-06-01T06:43:55+00:00

If I understand the Binding of posted JSon data to an action’s parameter in

  • 0

If I understand the Binding of posted JSon data to an action’s parameter in asp.net mvc 3, I have nothing special to do.

For example :

[HttpPost]
public JsonResult Synchro(TestJSON data)
{
  ... data member should contain the JSon data sent...
  return Json("ok" );
}

The TestJSON class :

public class TestJSON
{
    public string chaine;
    public int nombre;
}

and JSon data :

{chaine:"Test",nombre:"23"}

(sent with curl.exe for testing)

But data members are allway null or 0 in Syncho function.

I’ve searched a lot and I can’t understand.

I found something strange. If I remove the JsonValueProviderFactory (in Application_Start) :

var v = ValueProviderFactories.Factories.OfType<JsonValueProviderFactory>().First();
ValueProviderFactories.Factories.Remove(v);

and if I create my own model binder (found somewhere on the bet) :

 public class JeanJsonModelBinder : IModelBinder
 {
    public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
    {
        if (!controllerContext.HttpContext.Request.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
        {
            // not JSON request
            return null;
        }

        var request = controllerContext.HttpContext.Request;
        var incomingData = new StreamReader(request.InputStream).ReadToEnd();

        if (String.IsNullOrEmpty(incomingData))
        {
            // no JSON data
            return null;
        }

        JavaScriptSerializer serializer = new JavaScriptSerializer();
        return serializer.Deserialize(incomingData, bindingContext.ModelType);
    }
  }

and if I manually bind my parameter :

[HttpPost]
public JsonResult Synchro([ModelBinder(typeof(JeanJsonModelBinder))] TestJSON data)
{
  ... data member should contains JSon data sent...
  return Json("ok" );
}

It works !

Any idea ?

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-06-01T06:43:57+00:00Added an answer on June 1, 2026 at 6:43 am

    Try using properties for your model class instead of datamembers.
    I think that if you replace the default model binder with yours it might work to but you should still use propertys because this is the standard mo.

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

Sidebar

Related Questions

ASP.NET MVC Model Binding is still new to me and I'm trying to understand
I'm trying to understand better how data binding works in .net. I was checking
I understand that Silverlight 3.0 has binding but just want a simple example on
As an exercise to learn wpf and understand how binding works I have an
I'm trying to better understand Silverlights binding mechanism and so have created a simple
Someone please help me understand why this binding does not work... I have a
I cannot understand the Silverlight documentation on data binding. I seek a very simple
I am just starting out with WPF and am trying to understand data binding.
Apparently I don't understand something about binding ListBox controls to data. Here is a
I'm kinda new to data binding and obviously don't really understand it. I'm trying

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.