IActionFilter vs IResultFilter

Please explain the difference between IActionFilter and IResultFilter. I understand that OnActionExecuting occurs before the action method is executed, and that OnActionExecuted occurs after the action method is executed, and also what it means to execute the action method. What I do not understand in the context of IResultFilter means that this means that the result of the action must be executed.

+4
source share
1 answer

Action filters contain logic that runs before and after the execution of a controller action. For example, you can use an action filter to modify view data that returns a controller action.

( IResultFilters) , . , .

.

, ViewResult, ViewResultBase:

      viewEngineResult = this.FindView(context);
      this.View = viewEngineResult.View;

      TextWriter output = context.HttpContext.Response.Output;
      this.View.Render(new ViewContext(context, this.View, this.ViewData, this.TempData, output), output);

, , Response.

+5

Source: https://habr.com/ru/post/1530153/


All Articles