Change the default model binder in asp.net MVC
Asked Answered
G

2

34

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

Godsend answered 12/4, 2009 at 10:53 Comment(0)
E
59
ModelBinders.Binders.DefaultBinder = new MyOwnModelBinder();
Emphysema answered 12/4, 2009 at 11:1 Comment(2)
Where does this go? In Global.asax.cs ? Or somewhere else?Unsuccess
i believe so... in MvcApplication.Application_Start()Sabellian
B
-1

In the Global.asax.cs:

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

    }
Brom answered 5/7, 2019 at 21:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.