Answer the question
In order to leave comments, you need to log in
ASP.NET Web API. How to wrap ControllerBase.BadRequest without dependency injection?
Hello! The task is as follows, I want to make a wrapper for BadRequest, passing an array of strings (errors), so that the front would receive the following format:
errMessage: [
"err1",
"err2"
]
return BadRequest(new { errMessage = listError });
public class ListMessageRequest : ControllerBase
{
public IActionResult BadRequest(string[] message)
{
return base.BadRequest(new { errMessage = message });
}
}
return BadRequest(FormatError.GetFormat(listError));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question