Hello am an trying to implement a global filter with injection. The filter looks like this.
public class WikiFilter : IActionFilter
{
private IWikiService se
I would recommend you using the ~/App_Start/NinjectMVC3.cs file to configure the Ninject kernel:
[assembly: WebActivator.PreApplicationStartMethod(typeof(AppName.App_Start.NinjectMVC3), "Start")]
[assembly: WebActivator.ApplicationShutdownMethodAttribute(typeof(AppName.App_Start.NinjectMVC3), "Stop")]
namespace AppName.App_Start
{
using System.Web.Mvc;
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
using Ninject;
using Ninject.Web.Mvc;
using Ninject.Web.Mvc.FilterBindingSyntax;
public static class NinjectMVC3
{
private static readonly Bootstrapper bootstrapper = new Bootstrapper();
///
/// Starts the application
///
public static void Start()
{
DynamicModuleUtility.RegisterModule(typeof(OnePerRequestModule));
bootstrapper.Initialize(CreateKernel);
}
///
/// Stops the application.
///
public static void Stop()
{
bootstrapper.ShutDown();
}
///
/// Creates the kernel that will manage your application.
///
/// The created kernel.
private static IKernel CreateKernel()
{
var kernel = new StandardKernel();
RegisterServices(kernel);
return kernel;
}
///
/// Load your modules or register your services here!
///
/// The kernel.
private static void RegisterServices(IKernel kernel)
{
kernel.Bind().ToSelf().InRequestScope();
kernel.Bind().To();
kernel.Bind().To();
kernel.BindFilter(FilterScope.Global, 0);
}
}
}
and the Global.asax stays unchanged. By the way that's the default setup when you install the Ninject.MVC3 NuGet package.