
276Microsoft Visual Studio 2010: A Beginner’s Guide
In the HTTP protocol, there are different types of verbs for the operation being conducted. Listing
The get Create action method instantiates a new Customer object and passes it to the View. When the user fills in the form and submits, the post Create action method will execute and insert the new record into the database.
Notice how I changed the Create method parameter from FormsCollection to Customer. ASP.NET MVC will automatically read the form values and match those values up with matching properties in the object passed to the method. The method also checks to ensure that the name is filled in and adds an error to the ModelState. Whenever an error occurs, you need to return to the same View to ensure the user sees the error and can correct and resubmit. ASP.NET MVC will use this error to display error messages in the View. To create the View,