Custom Error message with HTTPStatusCodeResult & jQuery

.net, asp.net-mvc-3, c#, http, jquery

Solution

Actually there wasn't any problem in the code at all. The problem was with the ASP.NET development Web Server in Visual Studio. I switched to using IIS express and it works fine.

Problem

I have a controller action that returns some JSON results to the jQuery Full Calendar plugin. I return a `HTTPStatusCodeResult` with a custom error message if there was an error, But I can't get the custom error message to display. All that's is displayed in the alert box is the default Http status (ie: 'Forbidden', or 'Internal Server Error') Controller code that returns the error messages ``` else if(id != CurrentUser.UserId) { return new HttpStatusCodeResult(403, "You are not authorised to view this."); } else { return new HttpStatusCodeResult(500, "There was an error on the server."); } ``` jQuery code ``` $(document).ready(function () { $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, height: 600, eventSources: [{ url: events, type: 'Get', error: function(response, status, error) { alert(response.statusText); } }], allDayDefault: false, selectable: true, eventClick: function (event) { if (event.url) { $('#details').load(event.url); } }, ```

Original source