不应用对IActionFilter中的响应对象所做的更改

时间:2020-01-14 13:19:43

标签: c# asp.net-core .net-core asp.net-core-2.2 action-filter

我正在IActionFilter中更改响应对象中的某些字段:

public async void OnActionExecuted(ActionExecutedContext context)
{
    ObjectResult actionResult = (ObjectResult)context.Result;
    IHavePrice havePrice = Cast<IHavePrice>(actionResult.Value);
    var items = await _priceSetter.GetPrices<IHavePrice>(username, new List<IHavePrice>() { havePrice });
    havePrice = items[0];    
}

代码有效:我可以看到context.Result.Value中的更改。但是在前端,我在响应对象中收到旧值。

0 个答案:

没有答案