mbrc
mbrc

Reputation: 3973

Method ActionFilterAttribute before controller ActionFilterAttribute

How to run method ActionFilterAttribute before controller ActionFilterAttribute

Example:

[Transaction(Order = 20)]
public class BaseController : Controller
    {
...
}

public class Test{} : BaseController {

[HttpPost]
        [WorkReportAccountsSettlementCreatedByCompanyDomainEvent]
        public virtual JsonResult Create(CreateStudentsWorkReportsListOverviewFormModel model)
        {
...
}

}

Problem is that TransactionAttribute is always executed before WorkReportAccountsSettlementCreatedByCompanyDomainEventAttribute

Why? I want oposite ...

Upvotes: 0

Views: 299

Answers (1)

MaKCbIMKo
MaKCbIMKo

Reputation: 2820

Why TransactionAttribute is executed before WorkReportAccountsSettlementCreatedByCompanyDomainEventAttribute is that the first one has the lower order. You can take a look at MSDN page where described all filters order.

If you will take a look on FilterScope enum you will see the following:

public enum FilterScope 
{
    First = 0,
    Global = 10,
    Controller = 20,
    Action = 30,
    Last = 100,
}

It means that even if you set Order = 20 it still will be executed before because Action = 30.

Upvotes: 1

Related Questions