title: ASP.NET mvc RenderAction Login And Register Views
body: <p>I am working on NopCommerce v3.80. By Default the login and register views are different. I needed to merge them without changing much of the code, so I called <code>@{ RenderAction("Register"); }</code> inside Login.cshtml.</p>
  
  <p>I also removed the layout (<code>Layout = "~/Views/Shared/_ColumnsOne.cshtml";</code>) from Register view.</p>
  
  <p>the problem is when a validation error like 'Email Id already Exists!' comes, it goes to the register view. I need to show the validation or error message on the login view. but the login view accepts only Login Model.</p>
  
  <p>Please see my code :</p>
  
  <p><strong>Register.cshtml</strong></p>
  
  <pre><code>@model RegisterModel 
  @using Nop.Web.Models.Customer;
  @{
      //Layout = "~/Views/Shared/_ColumnsOne.cshtml";
  }
  
  &lt;!-- Registeration fields  --&gt;
  </code></pre>
  
  <p><strong>Login.cshtml</strong></p>
  
  <pre><code>@model LoginModel
  @using Nop.Web.Models.Customer;
  @{
      Layout = "~/Views/Shared/_ColumnsOneTT.cshtml";
  }
  
  @using (Html.BeginForm("Register", "Customer", FormMethod.Post)){
  &lt;div&gt;  
  @{ 
      Html.RenderAction("Register");
   }
  &lt;input type="submit" value="Submit"/&gt;
  }
  </code></pre>
  
  <p><strong>CustomerController.cs</strong> - Register Method</p>
  
  <pre><code>public ActionResult Register(RegisterModel model){
      // Lot of code
      if (success){
      // lot of code
         return RedirectToRoute("RegisterResult");
      }
      foreach (var error in registrationResult.Errors)
         ModelState.AddModelError("", error);
      PrepareCustomerRegisterModel(model, true, customerAttributesXml);
      return View(model);
  
  }
  </code></pre>
  
  <p><strong>UPDATE :</strong> I checked <a href="https://stackoverflow.com/questions/17860208/how-to-work-with-two-forms-in-a-single-view">how to work with two forms in a single view</a> but it won't help me as I can not go with new model creation option. </p>
  
  <p><strong>UPDATE 2:</strong> I also tried with the new model creation option which covers the login and register models but I am still getting the same result.</p>