Is it possible to pass strongly typed custom object from view to controller action method in a get or post request (not the model object which is used to bind data in the view)?. I have a view model object which has an "event type" property and then few other properties as event arguments. for every post or get request from the view, I want to create an instance of this view model object and pass the event type (event type indicates what action is done by the user as an enum and set the required properties). the object is created by the model binder, but the values are not getting populated. but if I pass anonymous object, then I can extract the values, but I need to declare a parameter for every property in the anonymous object, which I want to avoid.
sample code:
@Ajax.ActionLink("link1","ActionMethod1", new EventData {EventType="event1",Arg1=@arg1})
@Ajax.ActionLink("link2","ActionMethod1", new EventData {EventType="event2",Arg2=@arg2})
Action Method:
[HttpPost]
public void HandleEvent(EventData eventData)
{
if (eventData != null)
{
//perform action
}
}