You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't get the Autofac model binding for MVC to work with subclasses - which I think is the intended behavior. The current Autofac model bind provider matches on exact type like the built in MVC one does.
Ideally it would be nice if the model binder could be registered to say I want to be used with the any subclasses that implement the specified type - i.e.
autofacModelBinderProvider.GetBinder(typeof(EntityImplementation)) would return EntityModelBinder
Is there a way to do this in the current implementation? My current solution is to create my own provider and resolve the binders thru the dependency resolver, but I would prefer to use a purely Autofac solution if possible.
The text was updated successfully, but these errors were encountered:
This is not currently supported. Most likely we won't enhance the behavior for the current integration just because it could pretty easily break (or change behavior in) apps that aren't expecting it. We also try to be consistent with the way things work in standard MVC so it's easy to figure out what to expect. However, the integration points for ASP.NET vNext are being worked on and that may be a good time to look at this.
In the meantime... your solution of a custom provider is probably the best way to go.
I can't get the Autofac model binding for MVC to work with subclasses - which I think is the intended behavior. The current Autofac model bind provider matches on exact type like the built in MVC one does.
Ideally it would be nice if the model binder could be registered to say I want to be used with the any subclasses that implement the specified type - i.e.
Ideally I would like to do something like this:
builder.RegisterType()
.AsModelBinderForTypesAndSubclasses(typeof(IEntity))
.PropertiesAutowired();
builder.RegisterModelBinderProvider();
autofacModelBinderProvider.GetBinder(typeof(EntityImplementation)) would return EntityModelBinder
Is there a way to do this in the current implementation? My current solution is to create my own provider and resolve the binders thru the dependency resolver, but I would prefer to use a purely Autofac solution if possible.
The text was updated successfully, but these errors were encountered: