7

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);
                     }
                 },

1 Answer 1

13

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I don't know why Microsoft has NOT fixed this yet. I've spent one hour or more today trying to see what I was doing wrong.
I wonder how many engineers are working on the VS Web Development Server these days? My guess is 0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.