Ninject Interceptor calling twice beforeinvoke and afterinvoke methods

391 Views Asked by At

I am developing an app in asp.net in which I am implementing the Ninject Interceptor in which I am binding/registering the service like

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

When I am calling the method of this service

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();
        }
}

The method BeforeInvoke is calling twice in TimeInterceptor. Why?

1

There are 1 best solutions below

0
On

Maybe you have both of Ninject.Extensions.Interception.DynamicProxy and Ninject.Extensions.Interception.Linfu installed? If it so, then try to use only one of it.