Как вернуть ReasonPhrase в ответ от ActionFilter (.NET Core) - PullRequest
1 голос
/ 20 марта 2019

Я делаю следующее в .NET Core MVC ActionFilter, чтобы вернуть запрещенный код состояния:

public override void OnActionExecuting(ActionExecutingContext context)
    {
        context.Result = new ContentResult()
        {
            StatusCode = (int)HttpStatusCode.Forbidden,
            Content = "Token header is missing",
            ContentType = "text/plain",
        };
        return;
    }

Это прекрасно работает, но я бы также хотел установить ReasonPhrase, который находится в классе "HttpResponseMessage", возвращаемом из вызывающего метода HttpClient.SendAsync. Как я могу установить ReasonPhrase из ActionFilter?

...