C#C
C#3y ago
HAHOOS

Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by...

Hello, I am working on an API in MVC and I want throw an exception, but I get the following error:
Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details.


I don't know what to do, I looked everywhere on the internet and nothing, here is my code for executing an error:

var resp = new HttpResponseMessage(HttpStatusCode.NotFound)
                {
                    Content = new StringContent(JsonConvert.SerializeObject("Code has been not found"), Encoding.UTF8, "application/json"),
                    ReasonPhrase = "Code Not Found",
                };
throw new HttpResponseException(resp);
Was this page helpful?