JSON input format is one of the most widely-used input formats for complex
data sharing. In an Ajax call, it is necessary to send complex data as
input according to the business requirements. Since, complex or large input
parameters are difficult to manage and share in Ajax call, therefore it
is recommended to utilize the power of JSON input format.
Today, I shall be demonstrating the integration of Ajax
call by passing JSON format input query parameters using the ASP.NET MVC5
platform.
Following are some prerequisites before you proceed any further in this tutorial,

Prerequisites
- Knowledge of Jquery.
- Knowledge of HTML.
- Knowledge of JavaScript.
- Knowledge of Bootstrap.
- Knowledge of ASP.NET MVC5.
- Knowledge of C# Programming.
Let's begin now.
Step 1
Step 1
Create a new MVC web project and name it "MVCAjaxWithJsonParam".
Step 2
Create target "JSON object Mapper" object class file according to the business requirements.
Step 3
Create a "Controllers\HomeController.cs" file with
default Index method and GetData(...) method with string type input query
parameters for Ajax call with following lines of code i.e.
- ...
- public ActionResult GetData(string jsonInput = "")
- {
- // Initialization.
- JsonResult result = new JsonResult();
- DataTable data = DataTable();
- ...
- // Deserialize Input JSON String into target Object Mapper.
- RequestObj reqObj = JsonConvert.DeserializeObject<RequestObj>(jsonInput);
- ...
- // Load Data.
- ...
- // Filter data with JSON input query parameters.
- ...
- // Prepare Ajax Response as JSON Data Result.
- result = this.Json(JsonConvert.SerializeObject(data), JsonRequestBehavior.AllowGet);
- ...
- // Return info.
- return result;
- }
- ...


William fabian Gonzalez CoboPosted Jul 17, 2020, 9:29 AM
Muchas gracias buen aporte