2
Vote

HttpStatusCodeResult does not set description correctly

description

Controller:

public ActionResult Update(SomeModel model)
{
if(SomethingIsWrong())
    return new HttpStatusCodeResult(500, "Something Went Wrong");

return Json(model);
}


Whenever I use this, Instead of my message "Something Went Wrong", I always get "Internal Server Error" as HTTP status error received in my ajax call using jQuery. If I am on php and I send a custom error message, I retrieve perfect error message the one I sent in the same client script.

Network Trace in IE, Chrome confirms that ASP.NET sends message "Internal Server Error" even if I have set different status message.

Also, changing custom errors mode on/off in web.config made no difference either.

comments

PhoenixHawk wrote May 13 at 1:23 PM

I can reproduce this when using the Visual Studio Development server (Cassini). When serving this through IIS the correct description is returned.