My controller action should be used for a set of models that inherit the Polis abstract class:
public abstract class Polis
{
protected Polis()
{
}
public Polis(Object input)
{
}
}
In the action of my control, the generic type must inherit this abstract class. But he does not see the constructor of the abstract class, which has an argument. Therefore, I must indicate that it implements 'new ()', instead I would like to use a constructor with an argument.
public virtual ActionResult SavePolis<TModel>(PolisPostModel polisPM) where TModel : Polis, new()
{
if (ModelState.IsValid)
{
}
return Json(new
{
success = ModelState.IsValid,
status = this.GetStatus(polisPM),
});
}
All data processing is done inside the inhereting classes, so I need the methods of the inheriting classes that will be executed. But when I try to call a controller action that indicates my particular type as an argument, it has the error "No overload for the SavePolis method takes 0 arguments":
@Html.Hidden("SaveMyPolis", Url.Action(MVC.Controller.SavePolis<MyPolis>())
, ? , , .