title: How to display ValidationSummary using multiple forms using MVC
body: <p>I have looked at many of the solutions on offer on this site and others for my problem but none of them seem to work perfectly for my solution.</p>
  
  <p>On my Layout page I have a login area on the top of the screen. This is always present unless a user is logged in. This login form has a ValidationSummary on it and every time I post back using another form on the site the validation for this login form is being triggered.</p>
  
  <p>I'm almost certain that this is down to how I call this login page from my Layout page. It is not a partial view that is in a Shared folder, it is in an Area in my project. On my Layout page I call the login form like this:</p>
  
  <pre><code>@Html.Action("LogOn", "Account", new { area = "Store" })
  </code></pre>
  
  <p>The logon page contains the following:</p>
  
  <pre><code>@model Project.ViewModels.LogOn_ViewModel
  
  @{
      Layout = null;
  }
  
  @using (Ajax.BeginForm("LogOn", "Account", new { @area = "Store" }, new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "LoginContainer", LoadingElementId = "actionLoaderImage" }, new { id="LogonForm" }))
  {
      @Html.AntiForgeryToken()
  
      &lt;div class="loginArea"&gt;
          &lt;div class="notRegistered"&gt;
              &lt;h4&gt;Not registered yet?&lt;/h4&gt;
              Register now&lt;br/&gt;
              @Html.ActionLink("Register", "Index", "SignUp", new { area = "Store" }, new { @class = "greenButton" })
          &lt;/div&gt; &lt;!-- /notRegistered --&gt;
  
          &lt;div class="loginForm"&gt;
              &lt;div class="formFields"&gt;
                  &lt;label class="inline"&gt;@Html.LabelFor(m =&gt; m.UserName)&lt;/label&gt;
                  @Html.TextBoxFor(m =&gt; m.UserName)
                  &lt;label class="inline"&gt;@Html.LabelFor(m =&gt; m.Password)&lt;/label&gt;
                  @Html.PasswordFor(m =&gt; m.Password)
                  &lt;input type="submit" name="LogIn" value="Log in" class="blueButton" /&gt;
                  &lt;img id="actionLoaderImage" src="@Url.Content("~/Content/web/images/loader.gif")" alt="icon" style="margin-right:15px; display:none;" /&gt; 
                  @Html.ValidationSummary()
              &lt;/div&gt;
          &lt;/div&gt; &lt;!-- /loginForm --&gt;
      &lt;/div&gt; &lt;!-- /loginArea --&gt;
  }
  </code></pre>
  
  <p>The login controller is standard stuff:</p>
  
  <pre><code>        // GET: /Account/Logon
  
          public ActionResult LogOn()
          {
              // if logged in show logged in view
              if (User.Identity.IsAuthenticated)
                  return View("LoggedIn");
  
              return View();
          }
  
  
          // POST: /Account/Logon
  
          [HttpPost]
          public ActionResult LogOn(LogOn_ViewModel model)
          {
              if (ModelState.IsValid)
              {
                  if (SecurityService.Login(model.UserName, model.Password, model.RememberMe))
                  {
                      return View("LoggedIn");
                  }
                  else
                  {
                      ModelState.AddModelError("", "The user name or password provided is incorrect.");
                  }
              }
              return PartialView(model);
          }
  </code></pre>
  
  <p>I suspect that what is happening here is that Html.Action is 'posting' the login form if a post is occurring elsewhere on the page. This makes sense as the layout page itself would be posted as part of a form post action.</p>
  
  <p>I tried implementing the custom Validator examples from some other SO questions and blogs (<a href="http://blogs.imeta.co.uk/MBest/archive/2010/01/19/833.aspx" rel="nofollow">http://blogs.imeta.co.uk/MBest/archive/2010/01/19/833.aspx</a>) but I found that using those examples would not display the validation summary with client side validation which is not much use to me.</p>
  
  <p>The solution I am looking for would need to allow both client and server side validations to appear for the correct form. Does anyone have an example of something like this using MVC? I'd like to avoid manually looking after the client side validation using jquery if possible and just to use the framework to handle the work for me.</p>
  
  <p>Thanks for your suggestions,
  Rich</p>