ModelBindingContext ModelName

别等时光非礼了梦想. 提交于 2019-12-22 09:39:07

问题


Can anyone explain where the ModelName gets populated from?

Looked in MSDN documentation and no explaination here. I am creating a custom model binder and within it I get null for the following: var result = bindingContext.ModelName);


回答1:


The ModelBindingContext object is created and populated by whoever calls into the BindModel() method. If the model is coming in as an argument to your action method, this is done by ControllerActionInvoker.GetParameterValue(), and the ModelName property will be set to the name of the parameter (unless overridden by [Bind(Prefix = ... )]).

If the model is being updated via UpdateModel(), the ModelBindingContext object is created by the UpdateModel() method itself. The ModelName parameter will be the prefix argument passed to UpdateModel().



来源:https://stackoverflow.com/questions/2519264/modelbindingcontext-modelname

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!