title: Validation not working in partial view
body: <p>I have an Index page which has two partial views: login and register.I am using data model validation.</p>
  
  <p>Login.cshtml</p>
  
  <pre><code>@model Project.ViewModel.UserModel
  
  &lt;div style="position:inherit;"&gt;
  @using (Html.BeginForm("_Login", "account"))
  {
      @Html.ValidationSummary(true)
      &lt;div class="label"&gt;@Html.Label("Username")&lt;/div&gt;
      &lt;div class="field"&gt;@Html.TextBoxFor(m =&gt; m.Username)&lt;/div&gt;
      &lt;div class="error"&gt;@Html.ValidationMessageFor(model =&gt; model.Username)&lt;/div&gt;
  
      &lt;div class="label"&gt;@Html.Label("Password")&lt;/div&gt;
      &lt;div class="field"&gt;@Html.PasswordFor(m =&gt; m.Password)&lt;/div&gt;
      &lt;div class="error"&gt;@Html.ValidationMessageFor(model =&gt; model.Password)&lt;/div&gt;
  
      &lt;input class="field" id="submit" type="submit" value="Login" /&gt;
  }
  </code></pre>
  
  <p></p>
  
  <p>Register.cshtml</p>
  
  <pre><code>@model Project.ViewModel.UserModel
  
  &lt;link href="~/Content/Site.css" rel="stylesheet" /&gt;
  &lt;div style="position: inherit; margin-top: 20px"&gt;
  @using (Html.BeginForm("_Register","account"))
  {
      &lt;div class="label"&gt;@Html.Label("Name")&lt;/div&gt;
      &lt;div class="field"&gt;@Html.TextBoxFor(m =&gt; m.FullName)&lt;/div&gt;
      &lt;div class="error"&gt;@Html.ValidationMessageFor(model =&gt; model.FullName)&lt;/div&gt;
  
      &lt;div class="label"&gt;@Html.Label("Username")&lt;/div&gt;
      &lt;div class="field"&gt;@Html.TextBoxFor(m =&gt; m.Username)&lt;/div&gt;
      &lt;div class="error"&gt;@Html.ValidationMessageFor(model =&gt; model.Username)&lt;/div&gt;
  
      &lt;div class="label"&gt;@Html.Label("Password")&lt;/div&gt;
      &lt;div class="field"&gt;@Html.PasswordFor(m =&gt; m.Password)&lt;/div&gt;
      &lt;div class="error"&gt;@Html.ValidationMessageFor(model =&gt; model.Password)&lt;/div&gt;
  
      &lt;div class="label"&gt;@Html.Label("Confirm Password")&lt;/div&gt;
      &lt;div class="field"&gt;@Html.PasswordFor(m =&gt; m.ConfirmPassword)&lt;/div&gt;
      &lt;div class="error"&gt;@Html.ValidationMessageFor(model =&gt; model.Password)&lt;/div&gt;
  
      &lt;div class="label"&gt;@Html.Label("Email")&lt;/div&gt;
      &lt;div class="field"&gt;@Html.TextBoxFor(m =&gt; m.Email)&lt;/div&gt;
      &lt;div class="error"&gt;@Html.ValidationMessageFor(model =&gt; model.Email)&lt;/div&gt;
  
      &lt;div class="label"&gt;@Html.Label("Country")&lt;/div&gt;
      &lt;div class="field"&gt;@Html.TextBoxFor(m =&gt; m.Country)&lt;/div&gt;
      &lt;div class="error"&gt;@Html.ValidationMessageFor(model =&gt; model.Email)&lt;/div&gt;
  
      &lt;input class="field" id="submit" type="submit" value="Sign Up" /&gt;
      @Html.ValidationSummary()   
  }
  </code></pre>
  
  <p></p>
  
  <p>Index.cshtml</p>
  
  <pre><code> @model Project.ViewModel.UserModel
   @{
      ViewBag.Title = "Index";
      Layout = "~/Views/Shared/_Layout.cshtml";
   }
  
  &lt;div id="regiserandlogin"&gt;
  &lt;div id="registerandlogin-header"&gt;
      &lt;label style="margin-left:50px;"&gt;Sign Up For Free!!!&lt;/label&gt;
      &lt;label style="margin-left:350px;color:#28a1e2"&gt;Already Have An Account?&lt;/label&gt;
     &lt;/div&gt;
     &lt;div id="registerbox"&gt;
          @Html.Partial("_Register", new ProjectHub.ViewModel.UserModel())
     &lt;/div&gt;
     &lt;div id="loginbox"&gt;
          @Html.Partial("_Login", new ProjectHub.ViewModel.UserModel())
     &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>    public ViewResult _Register()
      {
          return View("_Register");
      }
      [HttpPost]
      public ActionResult _Register(UserModel usermodel)
      {
          if (!ModelState.IsValid)
          {
              return View("Index");
          }
          try
          {
              FormsAuthentication.SetAuthCookie(usermodel.Username, false);
              return RedirectToAction("activationemail", new {username= Username});
          }
          catch (Exception ae)
          {
              ModelState.AddModelError("", ae.Message);
              return View();
          }
      }
     public ViewResult _Login()
      {
          return View("_Login");
      }
      [HttpPost]
      public ActionResult _Login(string username, string password)
      {
          if (ModelState.IsValid)
          {
              if (MembershipService.ValidateUser(username, password))
              {
                  if (!repository.IsVerified(username))
                  {
                      ModelState.AddModelError("","Account is not activated.;
                      return View();
  
                  }
                  FormsAuthentication.SetAuthCookie(username,false);
                    return RedirectToAction("Index","Home");
  
              }
              return RedirectToAction("Index", "account"); ;    
          }
          else
          {
              ModelState.AddModelError("","Invalid Username/Password");
              return View();
          }
      }
  </code></pre>
  
  <p>UserModel.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel.DataAnnotations;
  using System.Linq;
  using System.Web;
  
  namespace ProjectHub.ViewModel
  {
      public class UserModel
      {
           [Required(ErrorMessage="Username is Required")]
           public string Username { get; set; }
           [Required(ErrorMessage = "Password is Required")]
           public string Password { get; set; }
           [Required(ErrorMessage = "Password is Required")]
           public string ConfirmPassword { get; set; }
           [Required(ErrorMessage = "Name is Required")]
           public string FullName { get; set; }
           [Required(ErrorMessage = "Email is Required")]
           public string Email { get; set; }
           [Required(ErrorMessage = "Country is Required")]
           public string Country { get; set; }
       }
   }
  </code></pre>
  
  <p>When I press register button like this, I get <a href="http://tinypic.com/view.php?pic=m819vm&amp;s=6" rel="nofollow noreferrer">a validation error</a></p>
  
  <p><img src="https://i.stack.imgur.com/iJbCu.png" alt="enter image description here"></p>
  
  <p>If I use RedirectToAction Method, I don't get the validation error.
  Please advise me.</p>