I have a page in the application that I am creating. The page contains several bits and parts, then a partial view, which loads a different view depending on what is selected in the drop-down list. Each of the options from the drop-down list has a different view associated with it, and each view has its own fields and model.
No matter what loads, I perform the same action - I serialize the model and save the XML in the database. This is always the case, and there is no unique processing based on views / models (except that the fields are different). All models are inherited from one base class for serialization purposes.
I wanted to be able to do something like:
public ActionResult SubmitPartialView<T>(T model)
{
BaseClass baseClassModel = (BaseClass)(object)model;
}
But MVC does not allow this - "cannot trigger an action on the controller, because the action is a common method."
If I try to pass BaseClass as the parameter itself, it contains only the properties of the base class and, therefore, none of the properties of the model.
Is there any other way besides creating a separate action for each separate view that can send, and make each of them call a separate method that processes the logic?
source
share