更改asp.net MVC中的默认模型绑定器

时间:2009-04-12 10:53:56

标签: asp.net-mvc

有什么方法可以将默认的ModelBinder设置为我自己的一个吗?

2 个答案:

答案 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();
        }

    }