I am developing an Asp.NET MVC5 project. In my project, I am creating a custom validation attribute. But I am having problem with retrieving posted form data from custom attribute. I am not retrieving property value of ViewModel. I need to retrieve only formcollection value or rote data value in action.
I have action like this
public ActionResult postData(ViewModel model, string routeDta)
{
//do action here
}
This is my custom attribute needs to retrieve route data
public class RemoteClientServerAttribute : RemoteAttribute
{
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
//I want to retrieve routeDta from action above here
//It is also ok if I can retrieve form collection value
}
public RemoteClientServerAttribute(string routeName)
: base(routeName)
{
}
public RemoteClientServerAttribute(string action, string controller)
: base(action, controller)
{
}
public RemoteClientServerAttribute(string action, string controller,
string areaName)
: base(action, controller, areaName)
{
}
}
I commented where I want to retrieve data. How can I retrieve form collection value or route data from custom attribute? I am not trying to retrieve property value from ViewModel.