Execute code before/after every controller action

前端 未结 3 1483
梦毁少年i
梦毁少年i 2020-12-24 13:42

I have an ASP.NET MVC application for which I want to log events. I have already a Log class with all the tools I need, but I have to instantiate and to close it explicitly

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-24 14:24

    you can use modules because they both sit in a pipeline and can provide pre and post processing for the core execution of a request. BeginRequest / ActionExecuting and EndRequest / ResultExecuted. They both also provide authorization hooks.

    http://msdn.microsoft.com/en-us/library/aa719858(v=vs.71).aspx

提交回复
热议问题