22 Aralık 2019 Pazar

Notes for a developer (about JSON)

What is this?

JSON: JavaScript Object Notation

Why is this?

I am migrating my data interoperability solutions from XML to JSON

Problem Definition: 

Cannot bind ViewModel data to the model (ASP.Net Core 3.0 Class) in the controller within an MVC solution. The model is always "null"

Found answer (What is the reason?): 

If the model data type mismatch with JSON data type the issue occurs (i.e. 18.0(floating) > 18(integer) or mismatch date format)

Relevant questions / topics:

How To Work With JSON In ASP.NET
How to pass json POST data to Web API method as an object?
Model and ViewModel in ASP.NET Core MVC Pattern What is the difference between JSONResult and ActionResult?
When to use JSONResult in MVC?

Model binding JSON POSTs in ASP.NET Core

Notes to myself:

This one is the best source packed beautifully: Retrieving json from view to model (controller)
This one is easy to find yet, easier to access from here: Tutorial: Create a web API with ASP.NET Core
ASP.NET - jsonresult vs actionresult in controller?

And Finally:

ASP.NET MVC - Using JavaScript with Ajax and Razor Partial Views
ASP.NET MVC - Using Ajax Helpers with Razor Partial Views