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:
Make sure the method in the controller is type ActionResult, not ViewResult.
I have an ErrorController that help me throwing the errors and showing a nice error page, the use
Response.StatusCode
to return a different StatusCodeEdit For returning message-only to ajax results I use something like this in an actionFilter