My simple test application works great off my local IIS server.
When I publish it my shared hosting environment (discountasp.net), The AJAX call
$("#calendar").fullCalendar({
eventSources: [{
url: '/Home/GetCurrentMonth',
type: 'Get',
error: function () {
alert('there was an error while fetching events!');
}
}]
});
fails. Firebug shows the get arriving with the proper params and gives a ‘404 Not Found’ error. And I can see that the controller method ‘GetCurrentMonth’ is never being called (with some log\audit code I put in).
As everything runs fine on my local IIS server and I can’t connect with IIS7 Manager to the remote site to get a ‘Failed Request Tracing’.. I’m kind of stuck.
If there is no magic web.config setting (oh please!) I would settle for a recommendation of a ‘shared hosting environment’ that supports ASP.NET MVC 3 where FullCalendar works and I’d move the application (my current hosting environment has been way less than helpful).
Never hardcode urls as you did. Always use url helpers when generating urls in an ASP.NET MVC application:
Or if this is in a separate javascript file in which you don’t have access to server side code one possibility is to use for example HTML5 data-* attributes, like this:
and then in your separate javascript file:
I bet 50 bucks the reason why your code doesn’t work when you deployed it is because there is a virtual directory appended by IIS. So the correct url is not
/Home/GetCurrentMonthbut/YourApplicationName/Home/GetCurrentMonth. To avoid all those problems you should always use helpers when generating urls.