In this article we are going to discuss about form data submission using @Html.BeginForm Helper method and passing the data to another view.
In this article we are using Tempdata for passing data between different controllers.
The main advantage of TempData is passing data between different controllers when redirect happens it retains data between controller to controller.
Firstly, we are going to create the MVC Solution
Select Empty Template and add MVC folder reference,

Add new Controller in Controllers folder,

Select MVC 5 Controller - Empty,

Give Conroller name as Home,

Add a View
Right click on the Action Name and add view,


Create Model class in Model folder,
- public class Employee
- {
- public string FirstName
- {
- get;
- set;
- }
- public string LastName
- {
- get;
- set;
- }
- public string Salary
- {
- get;
- set;
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Model_Binding_in_Diffrent_Ways.Models;
- namespace Model_Binding_in_Diffrent_Ways.Controllers
- {
- public class HomeController: Controller
- {
- // GET: Home
- public ActionResult Index()
- {
- Employee emp = new Employee();
- return View(emp);
- }
- [HttpPost]
- public ActionResult SubmitEmp(Employee emp)
- {
- TempData["Emp"] = emp;
- return Redirect("/Home/EmpDetails");
- }
- public ActionResult EmpDetails()
- {
- Employee emp = TempData["Emp"] as Employee;
- return View(emp);
- }
- }
- }






Rakesh KalluriPosted Dec 28, 2015, 9:43 PM
Thanks to all
Ankur MistryPosted Dec 27, 2015, 12:10 PM
Helpful info. Thanks for sharing
Santhakumar MunuswamyPosted Dec 27, 2015, 9:04 AM
Thanks for nice article