title: asp.net MVC “create view” and data
body: <p>I have a Create view which uses a model for, oh let’s say a Customer. On the <code>HttpGet</code> if I pass no Customer object just as most tutorials, then I cannot use any statements like<code>@Model.CustomerID</code> etc. if I did choose to use the <code>@Model.xxxx</code> statements they would fail for a lack of a Customer object. so all is well since on a Create view there is no need for data in the <code>HttpGet</code> request on a Create view.</p>
  
  <p>Then when the user enters all of the data requested and clicks the Submit button my JavaScript begins validation. Suppose though I don’t check or can’t check for every possible error. The post-back occurs and the server validation code finds an error. I want to post the server side validation errors in the Create view. No problem since I have a validation summary on the page. However, since there are no <code>@Model.xxxxx</code> statements on the view to extract data from the model the customer’s data is ignored and he is only shown the error messages. Of course, the fix to that would be to pass a Customer object as a model on both the <code>HttpGet</code> and <code>HttpPost</code>.</p>
  
  <p>I would then pass a Customer object with strings initialized to <code>string.Empty</code> and ints etc initialized to 0 or whatever. Then I add <code>@Model.xxxxx</code> statements to extract the data. Of course, the data is extracted on both the <code>HttpGet</code> and <code>HttpPost</code> but that’s ok because of how I initialized the Customer object as mentioned above.</p>
  
  <p>I have done all this and it works but is this following best practices? Did I go awry somewhere?</p>