Register your own linking device in MVC 4

In MVC 3, I created custom model bindings by creating a new class that implemented Systen.Web.Mvc.IModelBinderand then registering it internally Global.asax.csand internally Application_Start()usingModelBinders.Binders.Add(typeof(sometype), new MyModelBinder());

In MVC 4, I understand what you should use System.Web.Http.ModelBinding.IModelBinderto implement pattern bindings.

I have two questions:

  • Why should we use model binding from System.Web.Http.ModelBindingrather than from Systen.Web.Mvc? I don’t see it listed as obsolete, so what's the problem with the old one?

  • If I am selling my connecting device from System.Web.Http.ModelBinding.IModelBinder, how can I register it inside my application so that it is really used?

+5
source share
1

( Global.asax.cs), System.Web.Mvc.IModelBinder.

System.Web.Http ASP.NET MVC Web API (.. -).

+5

All Articles