Dear all
I would like to make application with the combination of web api controllers and mvc controllers both I installed following nuget packages
1. unity.mvc4
3. unity.webapi
4. webapi
and I want to impliment dependency injection but I am having problem with dependency resolver
I can call my methods in mvc controller by using Bootstrapper.cs class that is created by default during unity.mvc4 package.
but when i added api controller and try to map my dependency then it is not working
I have searched some solutions as following
http://stackoverflow.com/questions/9527988/cannot-inject-dependencies-into-asp-net-web-api-controller-using-unity[
^]
But In above example I am having error on following
System.Web.Http.GlobalConfiguration.Configuration.ServiceResolver.SetResolver
ServiceResolver (red under line not found)
and
private static IUnityContainer BuildUnityContainer()
{
var container = new UnityContainer().LoadConfiguration();
return container;
}
LoadConfiguration() Not found
I also set unity detail in web.config as per my requiment
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<container>
<register type="PersonalShopper.Repositories.IProductListRepository, PersonalShopper.Repositories" mapTo="PersonalShopper.Implementations.MongoRepositories.ProductListRepository, PersonalShopper.Implementations" />
</container>
</unity>
Please suggest me what I am missing
and please suggest me a sample code for bot mvc controller and web api controller
With regards
Manoj