Does anyone know how to use AsyncController in an mvc application that uses Ninject for DI?
AsyncController works great when I don't use ninject, but I can't get them to work together.
I added the following to my sitemodule, but did not go.
Bind<IAsyncController>( ).To<AsyncController>( ).InSingletonScope( );
sorry that I do not explain it in detail.
my controller is as follows
[HandleError] public class HomeController : AsyncController { public void IndexAsync( ) { AsyncManager.OutstandingOperations.Increment( ); RssFeed feed = new RssFeed( ); feed.GetRssFeedAsyncCompleted += ( s, e ) => { AsyncManager.Parameters[ "items" ] = e.Items; AsyncManager.OutstandingOperations.Decrement( ); }; feed.GetRssFeedAsync( "http://feeds.abcnews.com/abcnews/topstories" ); } public ActionResult IndexCompleted( IEnumerable<SyndicationItem> items ) { ViewData[ "SyndicationItems" ] = items; return View( ); } }
and my global.asax looks like this:
public class MvcApplication : System.Web.HttpApplication { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default",
this works great. but as soon as I use ninject (ninject 2.0), I get a 404 page error when I try to access the index page. this is how i configure ninject
public class MvcApplication : NinjectHttpApplication //System.Web.HttpApplication { #region IOC static IKernel container; public static IKernel Container { get { if ( container == null ) { container = new StandardKernel( new SiteModule( ) ); } return container; } } protected override IKernel CreateKernel( ) { return Container; } #endregion public static void RegisterRoutes( RouteCollection routes ) { routes.IgnoreRoute( "{resource}.axd/{*pathInfo}" ); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults ); } //protected void Application_Start() //{ // AreaRegistration.RegisterAllAreas(); // RegisterRoutes(RouteTable.Routes); //} protected override void OnApplicationStarted( ) { AreaRegistration.RegisterAllAreas( ); RegisterRoutes( RouteTable.Routes ); } } public class SiteModule : NinjectModule { public override void Load( ) { } }
Do I need to snap something on my sitemodule?
By the way, I use the example of Jeff Prosez, which he published on his blog. Here you can download his demo application and try Ninject-ify :)
Any help was appreciated.