我正在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中调用两次。为什么呢?
答案 0 :(得分:0)
也许您同时安装了Ninject.Extensions.Interception.DynamicProxy
和Ninject.Extensions.Interception.Linfu
?如果是这样,那么尝试只使用其中一个。