Ninject Interceptor在调用之前和afterinvoke方法之前调用两次

时间:2013-01-21 06:09:11

标签: c# asp.net ninject ninject-extensions ninject-interception

我正在asp.net中开发一个应用程序,我正在实现Ninject Interceptor,我在其中绑定/注册服务,如

kernel.Bind<IPracticeManagement>().To<PracticeManagementClient>().InRequestScope().Intercept().With<TimingInterceptor>();

当我调用此服务的方法时

public class HomeController : Controller
    {
        private readonly IPracticeManagement _practiceManagement;

        public HomeController(IPracticeManagement practiceManagement)
        {
            this._practiceManagement = practiceManagement;
        }

        public ActionResult Index()
        {

            var specialities = this._practiceManagement.GetSpecialty();

            this.ViewBag.Specialities = specialities;

            ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";

            return View();
        }
}

BeforeInvoke方法在TimeInterceptor中调用两次。为什么呢?

1 个答案:

答案 0 :(得分:0)

也许您同时安装了Ninject.Extensions.Interception.DynamicProxyNinject.Extensions.Interception.Linfu?如果是这样,那么尝试只使用其中一个。