有什么方法可以将默认的ModelBinder设置为我自己的一个吗?
答案 0 :(得分:58)
ModelBinders.Binders.DefaultBinder = new MyOwnModelBinder();
答案 1 :(得分:-1)
在 Global.asax.cs 中:
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
//...
ModelBinders.Binders.DefaultBinder = new MyModelBinder();
}
}