I'm using Action Filter in MVC 3.
My question is if I can crafting the model before it's passed to the ActionResult in OnActionExecuting event?
I need to change one of the properties value there.
Thank you,
I'm using Action Filter in MVC 3.
My question is if I can crafting the model before it's passed to the ActionResult in OnActionExecuting event?
I need to change one of the properties value there.
Thank you,
There's no model yet in the
OnActionExecuting
event. The model is returned by the controller action. So you have a model inside theOnActionExecuted
event. That's where you can change values. For example if we assume that your controller action returned a ViewResult and passed it some model here's how you could retrieve this model and modify some property:If you want to modify the value of some property of the view model that's passed as action argument then I would recommend doing this in a custom model binder. But it is also possible to achieve that in the
OnActionExecuting
event: