Header add

 In this article we will discuss Form Submit (Post) Example in ASP.Net Core MVC.

Here we discuss how to create Form Fields and then send data from View to Controller using Form Collection in ASP.Net Core MVC..

Before start this article, please visit our previous article Difference between IHostingEnvironment and IWebHostEnvironment

The Action method for POST operation accepts the values of First Name, Last Name and Address sent from the View and it is assigned to a ViewBag object.

The View consists of an HTML Form which has been created using the Razor Tag attributes with the following attributes.
asp-action – Name of the Action. In this case the name is Index.
asp-controller – Name of the Controller. In this case the name is Home.
method – It specifies the Form Method i.e. GET or POST. In this case it will be set to POST.
There are three TextBox fields created for capturing values for First Name, Last Name and Address. There’s also a Submit Button at the end of the Form and when the Button is clicked, the Form is submitted.
Finally, the values of the ViewBag object is displayed using Razor syntax.


Let's run the application and see the result like below. You can see that when we type text on input boxes form submit/post the data into controller and it return the result.

Form Submit (Post) Example in ASP.Net Core MVC
</> Find the Source Code in Github

 In this tutorial we discussed Form Submit (Post) Example in ASP.Net Core MVC. If have any question related to this topic then give your feedback.

You May Also Like...

Post a Comment

Previous Post Next Post