title: Is it possible to use Data Annotations to validate parameters passed to an Action method of a Controller?
body: <p>I am using Data Annotations to validate my Model in ASP.NET MVC. This works well for action methods that has complex parameters e.g,</p>
  
  <pre><code>public class Params  
  {  
      [Required] string Param1 {get; set;}   
      [StringLength(50)] string Param2 {get; set;}  
  }
  
  
  ActionResult MyAction(Params params)  
  {  
     If(ModeState.IsValid)  
     {  
        // Do Something  
     }  
  }
  </code></pre>
  
  <p>What if I want to pass a single string to an Action Method (like below). Is there a way to use Data Annotations or will I have to wrap the string into a class?</p>
  
  <pre><code>ActionResult MyAction(string param1, string param2)  
  {  
     If(ModeState.IsValid)  
     {  
       // Do Something  
     }  
  }  
  </code></pre>