title: What is the point of the key parameter in ModelState.AddModelError in ASP.NET MVC?
body: <p>I've added validation checks in my controller that modify the <code>ModelState</code> if the validation fails.</p>
  
  <p>For example:</p>
  
  <pre class="lang-cs prettyprint-override"><code>private bool ValidateMoney(string raw, string name, decimal min, decimal max) {
      try {
          var dec = Convert.ToDecimal(raw);
  
          if (dec &lt; min) {
              throw new ArgumentOutOfRangeException(name + " must be &gt;= " + min);
          }
          else if (dec &gt; max) {
              throw new ArgumentOutOfRangeException(name + " must be &lt;= " + max);
          }
      }
      catch (Exception ex) {
          ModelState.AddModelError(name, ex.GetUserMessage());
      }
      return ModelState.IsValid;
  }
  </code></pre>
  
  <p>However, I never know value to pass for the <code>key</code> parameter in <code>ModelState.AddModelError</code>. (In the example, I just set it to my UI display name.) </p>
  
  <p>What is the parameter for and how should I use it?</p>