MVC Core里的特殊路由 -- IAlwaysRunResultFilter
用于无论什么时候都要执行的Action标记,应用场景--记录谁尝试访问过当前网址,无论他是否成功访问
代码:
public class CustomResultCancelBeforeFilterAttribute : Attribute, IFilterMetadata, IOrderedFilter, IResultFilter, IAlwaysRunResultFilter
{
public int Order { get; set; }
public void OnResultExecuted(ResultExecutedContext context)
{
Console.WriteLine($"This {nameof(CustomResultCancelBeforeFilterAttribute)} OnResultExecuted {this.Order}");
}
public void OnResultExecuting(ResultExecutingContext context)
{
Console.WriteLine($"This {nameof(CustomResultCancelBeforeFilterAttribute)} OnResultExecuting{this.Order}");
}
}