1

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?

Billz
  • 1,067
  • 6
  • 25
  • 57
  • Have you put a break point in `GetSpecialty` is it called once or twice? Also how is your `TimingInterceptor` implementation look like? – nemesv Jan 21 '13 at 06:11
  • GetSpecialty is calling once. – Billz Jan 21 '13 at 06:12
  • Then you should put a breakpoint in BeforeIncoke and check `invocation` maybe it request the `GetSpecialty` and a different method for the second time... – nemesv Jan 21 '13 at 06:15
  • I want to know which attribute of invocation has relevant information. There are alot of attributes in the invocation. – Billz Jan 21 '13 at 06:18
  • For start you should look the at the `invocation.Request.Method` to get which method is currently intercepted. Then the `invocation.Request.Context.Request.ParentRequest.Service` to check whether it both times your controller. – nemesv Jan 21 '13 at 06:35
  • Both times invocation.Request.Method and invocation.Request.Context.Request.ParentRequest.Service are same. :( – Billz Jan 21 '13 at 06:43
  • Hey there - did you find a solution for this problem? I'm encountering it too. – Jochen van Wylick Aug 12 '13 at 16:52

1 Answers1

0

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.

Adiono
  • 1,034
  • 11
  • 19