find and solve ||
Please wait.....

How to post form data in asp net Core

How to post form data in asp net Core

 In this source code project, we will explain with an example, how to submit (post) a Form and send data from View to Controller in ASP.Net Core MVC.

Posting data from the View page to the Controller is the basic need of any software system. Mostly, if we are using the ASP.Net Core MVC Razor page as frontend then we need to post the form data from view to controller using Ajax post.

Step 1.

Create New Project in core

Step 2.

Add ViewModel class under Models folder and place this code as given below

namespace PostDataUsingAjax.Models

    public class StudentInfoViewModel
        public int StudentId { get; set;}
        public string FirstName { get; set; }
        public string LastName { get; set;}
        public string Address { get; set;}

Step 3.

Create a New View page as Create.cshtml from your HomeController like as given below

When we  click on Razor View-Empty you will see like as given below

Create post method in your HomeController.cs like as given below.


        public IActionResult Create(StudentInfoViewModel model)
            if (ModelState.IsValid)
                return Json("Request Success");
            return Json("Request Failed");


Mahira  khanna

Mahira khanna

I have the skills you need for you company blog, website, or other content materials


Report Response