How can I change sent data to controllers some where like OnActionExcuting?
Imagine I want develop a middle ware (something like asp.net attributes) replace all "a" to "A" and then bind values to model(in all action just can see "A"!)
You can create a custom ModelBinder and use it on specific actions:
[HttpPost]
public ActionResult CreateSomething([ModelBinder(typeof(MyCustomModelBinder))] Something something)
{
}
public class MyCustomModelBinder : DefaultModelBinder
{
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
// Do something
return base.BindModel(controllerContext, bindingContext);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.