title: ASP.NET MVC 3 update field before validation
body: <p>The problem I'm having right now it's that ASP.NET MVC validates the request object, <em>user</em> in this case</p>
  
  <pre><code>public ActionResult Edit(User user)
  </code></pre>
  
  <p>What I want to do is that if the user's password is left blank, do not update the password, just use the old password, but if it's set, update it.</p>
  
  <p>The problem is that the framework complains that user does not has a password, even if I update the <em>user</em> object, it complains</p>
  
  <pre><code>public ActionResult Edit(User user)
  {
      user.Password = "Something";
  
      // more code...
  }
  </code></pre>
  
  <p>Apparently it does the validation on the request object, is there a way I can skip the validation in this case, or at least delay it until I finished modifying the user object?</p>
  
  <p>This is the full method code</p>
  
  <pre><code>[HttpPost]
  public ActionResult Edit(User user)
  {    
      if (string.IsNullOrEmpty(user.Password))
      {
          var oldUser = db.Users.Single(u =&gt; u.Id == user.Id);
          user.Password = oldUser.Password;
      }
  
      try
      {
          db.SaveChanges();
          return RedirectToAction("Index");
      }
      catch
      {
          return View(user);
      }
  }
  </code></pre>