I am using a custom modelbinder in a MVC5 project like this:
public class TypedModelBinder : IModelBinder, IModelBinderProvider {...}
This classes constructor has some dependencies that I need Autofac to inject for me. Then I have registered the custom modelbinder in Autofac like this:
builder.RegisterType<TypedModelBinder>()
.As<IModelBinderProvider>()
.InstancePerRequest();
Now I want to inspect some of the injected dependencies. I have put a breakpoint in the class constructor code, but I can not see that it gets hit when making new requests. Probably it only gets hit on the first request, but I cannot see that because the debugger is not attached yet then. The main method public virtual object BindModel(...)
does get hit though. I am pulling my hair out why the constructor is never hit. Anyone knows how Autofac, or MVC, creates and re-uses modelbinder classes?
Maybe these are only created once by MVC and then re-used?