Use Ninject.Wcf in ASP.NET MVC3. Output from NinjectWcfApplication disables the application

I am using AJAX-enable web services in my ASP.NET MVC3 application and I want to add some classes to them. So I installed NInject.Wcf, set the factory to Ninject.Extensions.Wcf.NinjectServiceHostFactory

, and the next step took the application class ( MVCApplication

in Global.asax) from NinjectWcfApplication

, but when I did, IIS stopped to start my application, it tries to use the StaticFile module, not the route request to controller.

How do I fix this, or how do I implement NInject with WCF in a different way?


source to share

1 answer

I finally figured it out, the reason the routes were misconfigured is due to the default Global.asax pattern for ASP.NET MVC application, by default it defines

void Application_Start() { ... }


and since HttpApplication does not use this method, IIS calls this method on startup. So when from NinjectWcfApplication

that has a specific Application_Start method, we need to change the default method:

protected override void Application_Start(object sender, EventArgs e)
    base.Application_Start(sender, e);


If we don't, IIS will call NinjectWcfApplication.Application_Start

our method instead Application_Start




All Articles