Is there any way I can set the default ModelBinder to one of my own?
Asked
Active
Viewed 6,338 times
2 Answers
59
ModelBinders.Binders.DefaultBinder = new MyOwnModelBinder();

Paco
- 8,335
- 3
- 30
- 41
-
Where does this go? In `Global.asax.cs` ? Or somewhere else? – Shiva May 20 '17 at 03:41
-
2i believe so... in MvcApplication.Application_Start() – user2565663 Jan 16 '18 at 07:18
-1
In the Global.asax.cs:
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
//...
ModelBinders.Binders.DefaultBinder = new MyModelBinder();
}
}