Change the default model binder in asp.net MVC

后端 未结 2 448
你的背包
你的背包 2020-12-15 03:16

Is there any way I can set the default ModelBinder to one of my own?

2条回答
  •  春和景丽
    2020-12-15 03:55

    In the Global.asax.cs:

    public class MvcApplication : System.Web.HttpApplication
        {
            protected void Application_Start()
            {
                //...
                ModelBinders.Binders.DefaultBinder = new MyModelBinder();
            }
    
        }
    

提交回复
热议问题