After Learning Jon Galloways MVC Music Store Example.I Just didn’t understood the create view How to pass model to controller in which we could see it from parameter in the action Create(Movie movie). Thanks.
[HttpPost]
public ActionResult Create(Movie movie)
{
if (ModelState.IsValid)
{
db.Movies.Add(movie);//Where is the movie come from?
db.SaveChanges();
return RedirectToAction("Index");
}
return View(movie);
}
In the code example you have posted, the Movie model will be created through model binding. During this process any of your form variables will be matched up with the object specified in the action.
For instance the value of
would be assigned to movie’s Title property.
A view can be associated with a model by declaring (Razor syntax)