Giter VIP home page Giter VIP logo

Comments (3)

tillig avatar tillig commented on August 28, 2024

From previous discussions on this issue, I'm gathering that a simple RegisterWebApiModelBinders one-call-does-it-all sort of method isn't really possible in Web API 2. We can augment existing support to allow registration of the types into the container in an easier fashion, but associating binder to type-being-bound is missing and isn't something we can reliably scan for.

I'd like to vote that we:

  • Mark the RegisterWebApiModelBinders method with an [Obsolete] attribute that includes a message explaining the challenges and encourages people to register individual binders for types.
  • Close the issue as 'wontfix' since there's not much we can really do.
  • In some TBD future release, remove the RegisterWebApiModelBinders method.

from autofac.webapi.

tillig avatar tillig commented on August 28, 2024

From @alexandrnikitin on June 16, 2014 18:43

From previous discussions on this issue, I'm gathering that a simple RegisterWebApiModelBinders one-call-does-it-all sort of method isn't really possible in Web API 2. We can augment existing support to allow registration of the types into the container in an easier fashion, but associating binder to type-being-bound is missing and isn't something we can reliably scan for.

Agreed, we should treat ModelBinders and ModelBinderProviders separately. Where RegisterWebApiModelBinders() register binders within container (they are available for MVC, eg ModelBinderAttribute) and AsModelBinderForTypes() registers binders for AutofacModelBinderProvider. AutofacModelBinderProvider isn't the only ModelBinderProvider there, e.g. ModelBinderAttribute also works as a provider.

I would leave RegisterWebApiModelBinders() as is, it does its job - scans assemblies for ModelBinders and registers them, like RegisterControllers() does.

from autofac.webapi.

tillig avatar tillig commented on August 28, 2024

In v4.0 the RegisterWebApiModelBinders method is marked obsolete and folks are encouraged to use the builder.RegisterWebApiModelBinderProvider() in combination with builder.RegisterType<T>().AsModelBinderForTypes(...) extension. Simply registering the model binders into the container isn't valuable because without the Autofac binder provider and the metadata, binders don't actually pass through DI.

from autofac.webapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.