OnActionExecuted和OnResultExecuting的区别 [英] Difference between OnActionExecuted and OnResultExecuting
问题描述
什么是OnActionExecuted和OnResultExecuting之间的区别?难道他们都曾经行动已被处理或没有的东西这两种方法之间发生的权利得到后对方开火。像视图引擎的初始化,...
What is the difference between OnActionExecuted and OnResultExecuting? Do they both get fired right after each other once the action has been processed or does something happen in between these two methods. Like the initialisation of the View Engine, ...
推荐答案
他们有不同的背景。
OnActionExecuted
有一个<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.mvc.actionexecutedcontext%28v=vs.100%29.aspx\">ActionExecutedContext在其中您可以查看由动作产生的结果。您还可以查看操作是否遇到异常,看看异常被处理的。
OnActionExecuted
has a ActionExecutedContext in which you can view the result produced by the action. You can also see whether the action encountered an Exception and see if the exception was handled.
OnResultExecuting
有一个<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.mvc.resultexecutingcontext%28v=vs.100%29.aspx\">ResultExecutingContext.这种方法被称为的ActionResult
实例调用之前。可以检查方法的结果和可能取消的结果的执行。这通常会导致与状态code 200的空白响应(你不能在OnActionExecuted方法做到这一点)。
OnResultExecuting
has a ResultExecutingContext. This method gets called just before the ActionResult
instance is invoked. You can examine the result of the method and possibly cancel the execution of the result. This will usually result in a blank response with status code 200. (you can't do this in the OnActionExecuted method).
这篇关于OnActionExecuted和OnResultExecuting的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!