【发布时间】:2008-11-14 07:27:35
【问题描述】:
基本上,我正在尝试在 ASP.NET HttpModule 中编写以下(伪代码):
*pre-code*
try { handler.ProcessRequest(...) }
catch (Exception) { *error-code* }
finally { *post-code* }
我发现我可以挂接到 HttpModule.PreExecuteHandler 的“预代码”和 .Error 的“错误代码”。但是 PostExecuteHandler 似乎运行不可靠。
BeginRequest 和 EndRequest 运行可靠,但对于我需要编写的代码来说还为时过早,这需要检查选择执行的处理程序。在 BeginRequest 之后才选择处理程序。
有编写这种包装器的最佳实践吗?
谢谢!
【问题讨论】:
标签: c# asp.net httpmodule