ASP.NET CORE 2.0 Hosting – Post The Data To ASP.NET MVC Controller Using JQuery Ajax

This blog will demonstrate, how to post the data to ASP.NET MVC controller(s) using JQuery Ajax. For that, I have created one controller “JQueryAjaxCallController” with the post action method “AjaxPostCall” and a class “Employee” as below.

Controller 

 

View
Next step is to add a View for the Controller and while adding it you will need to select the Employee class created earlier.

Once you click the Add button, it will create strongly typed view with Employee model. Now we need to create Razor/Html controls to get the user input. Here, I used the HTML controls to get user input and we made a jQuery Ajax Post to call MVC controller in the below code.

 

Detailed Description
1

The JSON.stringify() method converts a JavaScript value to a JSON string. It’s optional when we are just passing parameter(s) with Values(s)

RouteConfig.Cs
You need to set your startup controller and view.