I have a common action filter, and I want to get the current model in the OnActionExecuting method. My current implementation is as follows:
public class CommandFilter<T> : IActionFilter where T : class, new() { public void OnActionExecuting(ActionExecutingContext actionContext) { var model= (T)actionContext.ActionArguments["model"]; } }
This works well if my names of all models are the same. But I want to use differnet model names.
How to solve this problem?
Edit
public class HomeController : Controller { [ServiceFilter(typeof(CommandActionFilter<CreateInput>))] public IActionResult Create([FromBody]CreateInput model) { return new OkResult(); } }
c # asp.net-core asp.net-core-mvc
adem caglin
source share