Render ViewModel errors on View if ModelState is not valid
<p>I have a form like following in my MVC application:</p>

<pre><code> @using (Html.BeginForm("Register", "User", FormMethod.Post))
    {
        &lt;div&gt;
            @Html.TextBoxFor(m =&gt; m.FirstName, new { placeholder = "First name", @class = "form-control", @type = "text" })
        &lt;/div&gt;
        &lt;div&gt;
            @Html.TextBoxFor(m =&gt; m.LastName, new { placeholder = "Last name", @class = "form-control", @type = "text" })
        &lt;/div&gt;
        &lt;div&gt;
            @Html.TextBoxFor(m =&gt; m.Email, new { placeholder = "Email", @class = "form-control", @type = "email" })
        &lt;/div&gt;
        &lt;div&gt;
            @Html.TextBoxFor(m =&gt; m.Password, new { placeholder = "Password", @class = "form-control", @type = "password" })
        &lt;/div&gt;
        &lt;div&gt;
            @Html.TextBoxFor(m =&gt; m.PasswordConfirm, new { placeholder = "Confirm password", @class = "form-control", @type = "password" })
        &lt;/div&gt;
        &lt;div&gt;
            @Html.DropDownListFor(model =&gt; model.SelectedCountryId, Model.Countries, new { @class="select2_single form-control select2-hidden-accessible", @tabindex = "-1" })
        &lt;/div&gt;
        &lt;div&gt;
            &lt;input class="btn btn-default submit" type="submit" value="Register" /&gt;
        &lt;/div&gt;
    }
</code></pre>

<p>My ViewModel looks like following:</p>

<pre><code>public class UserRegistrationViewModel
{
    [Required(ErrorMessage = "First name is required!")]
    public string FirstName { get; set; }

    [Required(ErrorMessage = "Last name is required!")]
    public string LastName { get; set; }

    [Required(ErrorMessage = "Email name is required!")]
    public string Email { get; set; }

    [Required(ErrorMessage = "Password name is required!")]
    public string Password { get; set; }

    [Required(ErrorMessage = "Password confirmation name is required!")]
    public string PasswordConfirm { get; set; }
    public int SelectedCountryId { get; set; }

    [Required(ErrorMessage = "Country needs to be selected!")]
    public SelectList Countries { get; set; }
}
</code></pre>

<p>And these are my two actions: </p>

<pre><code>public ActionResult Index()
{
    var model = new UserRegistrationViewModel();
    var countries = Connection.ctx.Countries.OrderBy(x =&gt; x.CountryName).ToList();
    model.Countries = new SelectList(countries, "CountryId", "CountryName");
    return View(model);
}
[HttpPost]

public ActionResult Register(UserRegistrationViewModel model)
{ 
    if (ModelState.IsValid)
    {
        var user = new Users();
        user.FirstName = model.FirstName;
        user.LastName =model.LastName;
        user.Email = model.Email;
        user.PasswordSalt = Helpers.PasswordHelper.CreateSalt(40);
        user.PasswordHash = Helpers.PasswordHelper.CreatePasswordHash(model.Password, user.PasswordSalt);
        user.CountryId = Convert.ToInt32(model.SelectedCountryId);
        user.Active = true;
        Connection.ctx.Users.Add(user);
        Connection.ctx.SaveChanges();
        var role = new UserRoles();
        role.RoleId = 2;
        role.UserId = user.UserId;
        role.Active = true;
        user.UserRoles.Add(role);
        Connection.ctx.SaveChanges();
        return RedirectToAction("Index");
    }
    return null;
}
</code></pre>

<p>Now my question here is what do I do if the model state is not valid (ie. display the error messages that I've set up in my ViewModel)??? </p>

<p>Do I just do `return View(); or ?? </p>

<p>I need to render those messages on my view now...</p>