.NET Model Bundles

I tried to create my own connecting device in my ASP.NET MVC 4 project. But I am stuck with iterfaces from IModelBinder. There are three IModelBinder VS interfaces. In the following namespaces.

using System.Web.Http.ModelBinding; using System.Web.Mvc; using System.Web.ModelBinding; bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext) object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext); bool BindModel(ModelBindingExecutionContext modelBindingExecutionContext, ModelBindingContext bindingContext); 

All related classes, such as ModelBindingContext , ModelMetadata strong> and others, are also duplicated. My friend and I cannot find out what the purpose of such a terrible code duplication is. Why didn't Microsoft developers extract common classes for co-assembly? As I understand it, one interface is used in MVC, one in Web Api, and what is the purpose of the third version? Are these interfaces independent or somehow interconnected with each other?

+8
c # model-binding
source share
1 answer

I am not MS folk, but I think the answer is -

  • System.Web.ModelBinding for ASP.Net WebForms Applications

http://msdn.microsoft.com/en-us/library/system.web.modelbinding(v=vs.110).aspx

The System.Web.ModelBinding namespace provides classes that allow you to bind data objects to ASP.NET Web Forms controls.

  1. System.Web.Mvc for ASP.Net MVC

http://msdn.microsoft.com/en-us/library/system.web.mvc(v=vs.118).aspx

The System.Web.Mvc namespace contains classes and interfaces that support the ASP.NET Model View Controller (MVC) view structure for creating a Web application. This namespace includes classes that represent controllers, controller factories, action results, views, partial views, model bindings, and more.

  1. System.Web.Http.ModelBinding for ASP.Net Web API

http://msdn.microsoft.com/en-us/library/system.web.http.modelbinding(v=vs.118).aspx

This is the namespace for Web API 2

In short, all three structures are independent of each other. And you must remember that they are expandable frames. Therefore, they must be preserved. If you do not need a specific one, then remove it from your reference assemblies. They are independent of each other. They are all from different frameworks, they are all used to achieve the best results.

This is a function of the intellisense or resharper tools that they can list. But you are the one who must choose the right one based on your structure and your needs. But usually they are all available in the full version of framework.net and probably do the same job.

+14
source share

All Articles