gpt4 book ai didi

asp.net-mvc - 如何使用 `BindModel(HttpActionContext actionContext...` 签名创建自定义模型绑定(bind)器?

转载 作者:行者123 更新时间:2023-12-03 10:33:14 24 4
gpt4 key购买 nike

我需要知道如何创建自定义 IModelBinder在 MVC 4 中,它已被更改。

必须实现的新方法是:

bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext);

最佳答案

有 2 个 IModelBinder 接口(interface):

  • System.Web.Mvc.IModelBinder 和以前的版本一样,没有改变
  • System.Web.Http.ModelBinding.IModelBinder Web API 和 ApiController 使用它。所以基本上在这个方法里面你必须设置actionContext.ActionArguments到相应的值。您不再返回模型实例。
  • 关于asp.net-mvc - 如何使用 `BindModel(HttpActionContext actionContext...` 签名创建自定义模型绑定(bind)器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9910346/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com