C# Ninject拦截器和asp.net web窗体
我正在我的项目中使用ninject,一切都进展顺利。但是我想用截取模式在我的网页上记录一些请求 我对此做了一些研究,找到了一个asp.net MVC解决方案,并尝试适应webforms,但它对我不起作用。我所做的是 创建从Ninject.Web.PageBase继承的PageBaseC# Ninject拦截器和asp.net web窗体,c#,asp.net,webforms,ninject,C#,Asp.net,Webforms,Ninject,我正在我的项目中使用ninject,一切都进展顺利。但是我想用截取模式在我的网页上记录一些请求 我对此做了一些研究,找到了一个asp.net MVC解决方案,并尝试适应webforms,但它对我不起作用。我所做的是 创建从Ninject.Web.PageBase继承的PageBase public partial class PageBase : Ninject.Web.PageBase { // some code } 使我的所有页
public partial class PageBase : Ninject.Web.PageBase
{
// some code
}
使我的所有页面从我的新PageBase继承
public partial class Default : PageBase
{
}
创建我的拦截器
public class WebFormsInterceptor : SimpleInterceptor
{
readonly Stopwatch _stopwatch = new Stopwatch();
protected override void BeforeInvoke(IInvocation invocation)
{
_stopwatch.Start();
}
protected override void AfterInvoke(IInvocation invocation)
{
_stopwatch.Stop();
string message = string.Format("Execution of {0} took {1}.",
invocation.Request.Method,
_stopwatch.Elapsed);
Log.Debug(message);
_stopwatch.Reset();
}
}
并尝试配置内核以拦截我的PageBase。。。但问题是,我不知道如何配置它
kernel.Bind(x =>
x.FromAssemblyContaining<myProject.PageBase>()
//mistery configurations....
.Configure(b =>
b.Intercept()
.With<WebFormsInterceptor>()
) //Intercept each method invocation
);
kernel.Bind(x=>
x、 FromAssemblyContaining()
//模糊不清的配置。。。。
.Configure(b=>
b、 截取
.与()
)//拦截每个方法调用
);
查看Elmah
“未发现错误”。运行Elmah@desperado查看此帖子也请好友查看Elmah
“未发现错误”。运行Elmah@desperado也请好友查看此帖子