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 fo开发者_运维百科r the following: var result = bindingContext.ModelName);
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().
精彩评论