Comments (3)
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.
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.
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)
- Dependency Issue on latest version on nuget HOT 2
- Bad async/await implementation causing loss of execution context. HOT 9
- Help - Autofac.WebApi2 Global Action FIlters Parameters injection failed HOT 1
- Please, consider to release the 4.2.0 version of the Nuget package HOT 2
- Could not load file or assembly 'Autofac, Version=3.0.0.0' when using Autofac.WebApi 3.1.0 HOT 3
- What should I do tp set the value of ControllerContext property after GetService method? HOT 3
- Cannot get Autofac to work with Web API HOT 2
- Performance: Use TryGetValue instead of ContainsKey() + indexer sequence HOT 3
- Registration of filters on base classes no longer work HOT 3
- Test Failures on Autofac 4.0.1 or Later HOT 8
- Autofac filters for specific 'async' action in a controller not working HOT 1
- Injecting a registered named service is not working as expected. HOT 1
- Autofac 5 was pushed to Github a few days ago along with MVC 5 but the current version of WebApi2 is not usable with it HOT 1
- Compatibility with Autofac v6 HOT 1
- Web requests never return when using Autofac, unless pre-resolved HOT 2
- HttpRequestMessage is disposed after the filters are resolved HOT 7
- Override Exception Filters executed last instead of first HOT 3
- Filters at controller scope not ran when action scoped filters exist. HOT 3
- Change CallContext to AsyncLocal HOT 5
- Self-hosted WebApi Custom Authorization Filter/Attribute using IAutofacAuthorizationFilter HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autofac.webapi.