本文介绍了实施IModelBinder时的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一套最佳实践实施时要使用 IModelBinder

I'm looking for a set of best practices to use when implementing IModelBinder.

我读过三个不同的MVC的书籍和每一个做一些稍微不同的东西,在它们的实现没有任何真正的解释。

I've read three different MVC books and each one does some slightly different stuff in their implementations without any real explanation.


  • 的Hanselman的,哈克,格思里,Conery设备书甚至没有提及 IModelBinder

  • 巴勒莫建议延长 DefaultModelBinder ,而不是直接执行 IModelBinder ,但我实在不明白如何利用好处

  • 桑德森提到更新现有的模型实例,以及调用 ModelState.SetModelValue()遵循惯例。

  • The Hanselman, Haack, Guthrie, Conery book doesn't even mention IModelBinder
  • Palermo recommends extending DefaultModelBinder rather than direct implementation of IModelBinder, but I don't really see how to leverage the benefits
  • Sanderson mentions updating existing Model instances, as well as calling ModelState.SetModelValue() to follow convention.

我只是想确保我的模型粘合剂是下列约定,那我正确地理解整个 ModelBindingContext

I just want to make sure that my model binders are following conventions, and that I properly understand the entire ModelBindingContext.

任何提示,技巧好的教程推荐?

Any tips, tricks, GOOD tutorials to recommend?

推荐答案

K斯科特·艾伦拥有约模型绑定一些提示:
<一href=\"http://odeto$c$c.com/blogs/scott/archive/2009/04/27/6-tips-for-asp-net-mvc-model-binding.aspx\">http://odeto$c$c.com/blogs/scott/archive/2009/04/27/6-tips-for-asp-net-mvc-model-binding.aspx.

K Scott Allen has some tips about Model Binding: http://odetocode.com/blogs/scott/archive/2009/04/27/6-tips-for-asp-net-mvc-model-binding.aspx.

这篇关于实施IModelBinder时的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 00:25