Change the default model binder in asp.net MVC

后端 未结 2 449
你的背包
你的背包 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();
            }
    
        }
    
    0 讨论(0)
  • 2020-12-15 04:08
    ModelBinders.Binders.DefaultBinder = new MyOwnModelBinder();
    
    0 讨论(0)
提交回复
热议问题