How to throw NotFound in Rest service without DTO response?


In my service I want to throw a NotFound response. I do this with:

throw HttpError.NotFound($$"UVC {request.UVC} not found");

However, in PostMan I get the 404 http response, but I also get response DTO with some values defaulting to 0.
How can use this, without null as the response?

What’s the definition of the Response DTO of the Service this was thrown?

You can ensure that there’s no response body by writing and ending the response in your Service, e.g:

base.Response.StatusCode = 404;
base.Response.StatusDescription = $$"UVC {request.UVC} not found";

Ok that worked! Thanks.