如何在控制器ActionFilterAttribute
ActionFilterAttribute
示例:
[Transaction(Order = 20)]
public class BaseController : Controller
{
...
}
public class Test{} : BaseController {
[HttpPost]
[WorkReportAccountsSettlementCreatedByCompanyDomainEvent]
public virtual JsonResult Create(CreateStudentsWorkReportsListOverviewFormModel model)
{
...
}
}
问题是TransactionAttribute
始终在WorkReportAccountsSettlementCreatedByCompanyDomainEventAttribute
为什么呢?我想要对方......
答案 0 :(得分:1)
为什么在TransactionAttribute
之前执行WorkReportAccountsSettlementCreatedByCompanyDomainEventAttribute
是第一个具有较低的顺序。
您可以查看描述所有过滤器顺序的MSDN page。
如果您要查看FilterScope
枚举,您会看到以下内容:
public enum FilterScope
{
First = 0,
Global = 10,
Controller = 20,
Action = 30,
Last = 100,
}
这意味着即使您设置了Order = 20
,它仍然会在Action = 30
之前执行。