I'm implementing fullcalendar v5 in my .NET CORE 3 MVC project. When hard-coding events everything works fine,but I cannot seem to get events from a JSON string working. The calendar is triggering the method to get the feed, but no events are rendered. I tried about everything, read more than 100 webpages and issues here in stack overflow, but to no avail.
Method in my MVC controller:
[HttpGet]
public string GetAllEvents(DateTime Start, DateTime End)
{
List<GetPromoCalendarEventsDto> calendarEvents = _promoCalendarAppService.GetAllEvents(Start, End).Result;
var result = JsonConvert.SerializeObject(calendarEvents);
return result;
}
Content result:
[
{"title":"Event one","start":"2020-06-13","end":"2020-09-01"},
{"title":"Event two","start":"2020-06-14","end":"2020-12-30"},
{"title":"Test 20200623.001Y","start":"2020-07-03","end":"2020-08-03"}
]
Javascript:
var calendarEl = document.getElementById('promocalendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'timeGridWeek',
events: 'PromoCalendar/GetAllEvents'
});
calendar.render();
Thanks in advance!
Solved! I have put [DontWrapResult] above the method and it worked. The framework I use (ABP) wraps the result with other data and double-encodes the JSON string.
Thanks to @ADyson for putting me on the right path!