MVC 2 post-render extensibility point (custom action filters, even?)
I've got an .net MVC2 project, and I can't find a m开发者_运维知识库ethod to override which will allow me to perform some logic following a page render...
I'm currently using the OnActionExecuted / OnActionExecuting (and the OnResultExecuting / OnResultExecuted in my controllers to do a variety of things, the important one here being to place some objects onto thread local storage(TLS) - current user, for example.
As such, I do the 'setup' of the TLS in the OnActionExecuting, but I can't do the 'teardown' until after the page has been rendered.
Any suggestions? I don't want to leave parts of the TLS setup.
specifically, my view is calling a property of an object which needs to access TLS before I tear it down.
Thanks, Dave
Your best bet for the location of the tear down is the Application_EndRequest event inside the global.asax.
I ended up overriding the 'OnResultExecuted' method.
精彩评论