Why can't I add my custom mediator to my global.asax folder?

I see examples around the world of people who customize their custom model bindings as follows:

// global.asax protected void Application_Start() { ModelBinders.Binders.Add(typeof(YourModel), new YourBinder()); } 

But when I try to do this, it does not compile ( .Binders not found). What gives?

+7
source share
1 answer

Turns out it was just a name conflict, because I put my own connecting device in the / namespace folder called "ModelBinders". You can fix this in two ways:

  • Rename the namespace / folder to another location, for example. CustomModelBinders
  • Use the full reference to ModelBinders as follows:

    System.Web.Mvc.ModelBinders.Binders.Add( /* ... */ );

+12
source

All Articles