i am using dependency injection with untity in my mvc app. Now I need to access my services from a display template (via /Views/Shared/DisplayTemplates) and I do not have a good idea how to handle this case. Currently i am using the DependencyResolver like
CustomerService service = DependencyResolver.Current.GetService<CustomerService>();
I’ve heard that this is as an anti pattern? What other way do I have?
If you use the type any where in you app (view or controllers) and if you are injecting the dependency using any dependency injector, DI container will take of injecting concrete type to the end consumer
yes I know the concepts, but I am asking for a concrete example how to use it in a cshtml view without a constructor….
I got the thing
check this out