I tried to use this:
return Request.CreateResponse(HttpStatusCode.InternalServerError, "My message");
also I tried this one:
return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "My message");
But I see 500 error on my browser though any message like "My message" are displayed.
To return a specific response code with a message from ASP.NET MVC controller use:
return new HttpStatusCodeResult(errorCode, "Message");
Make sure the method in the controller is type ActionResult, not ViewResult.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With