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,
public class Params
{
[Required] string Param1 {get; set;}
[StringLength(50)] string Param2 {get; set;}
}
ActionResult MyAction(Params params)
{
If(ModeState.IsValid)
{
// Do Something
}
}
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?
ActionResult MyAction(string param1, string param2)
{
If(ModeState.IsValid)
{
// Do Something
}
}