Hi,
I'm trying to get Ninject to work with a project that is using a self hosted WebApi.
I've installed the nuget package Microsoft
ASP.NET Web API 2.2 Self Host (Microsoft.AspNet.WebApi.SelfHost) along with Ninject.Web.Common.Selfhost.
The console app seems to load up correctly, but I only seem to get a connection error when hitting my URL (
http://localhost:8081/api/hello). I have a similar test app that is not using Ninject that works correctly.
Am I missing something to get this going? I originally tried using the package Microsoft.AspNet.WebApi.OwinSelfHost but could not get it functioning because of various errors. If this is what I need to be using, I can revisit this.
public class HelloController : ApiController
   {
       public string Get()
       {
           return "Hello, world!";
       }
   }
   class Program
   {
       static void Main(string[] args)
       {
           var webApiConfiguration = new HttpSelfHostConfiguration("http://localhost:8081");
           webApiConfiguration.Routes.MapHttpRoute(
                       name: "DefaultApi",
                       routeTemplate: "api/{controller}/{id}",
                       defaults: new { id = RouteParameter.Optional });            var mSelfHost = new NinjectSelfHostBootstrapper(CreateKernel, webApiConfiguration);
           mSelfHost.Start();
           Console.ReadLine();
       }
       private static IKernel CreateKernel()
       {
           var mKernel = new StandardKernel();
           mKernel.Load(Assembly.GetExecutingAssembly());
           return mKernel;
       }
   }
Here are the packages I have installed:
<packages>
 <package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
 <package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
 <package id="Microsoft.AspNet.WebApi.SelfHost" version="5.2.2" targetFramework="net45" />
 <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
 <package id="Ninject" version="3.2.2.0" targetFramework="net45" />
 <package id="Ninject.Web.Common" version="3.2.3.0" targetFramework="net45" />
 <package id="Ninject.Web.Common.Selfhost" version="3.2.3.0" targetFramework="net45" />
</packages>