Reputation: 31
After much googling, trail and error, and frustration, this one has me stumped.
I have an MVC application published on Azure. I have a controller that queries the database and returns Json file to use as events in Fullcalendar as so:
public JsonResult Events()
{
var ci = from c in db.CalendarItems
select c;
var rows = new List<dynamic>();
foreach(var item in ci)
{
if (item.ClassTime.HasValue)
rows.Add(new { ID = item.Id, title = item.title, start = item.start.ToString("yyyy-MM-dd") + "T" + item.start.TimeOfDay.ToString(@"hh\:mm\:ss"), end = item.end.ToString("yyyy-MM-dd") + "T" + item.end.TimeOfDay.ToString(@"hh\:mm\:ss")});
}
return Json(rows, JsonRequestBehavior.AllowGet);
}
Very simple... On my local, this generates a perfectly good file that looks like this:
[{"ID":1,"title":"Event1","start":"2015-08-04T19:00:00","end":"2015-08-04T08:00:00"},{"ID":2,"title":"Event2","start":"2015-08-06T19:00:00","end":"2015-08-06T08:00:00"},{"ID":3,"title":"Event3","start":"2015-08-14T19:00:00","end":"2015-08-14T08:00:00"}]
However, on the published azure site I get an error code 500.
Here is what I have tried so far:
Adding this to web.config:
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
Adding httpErrors existingResponse = "PassThrough" to system.webServier in my web.config.
Lot's of tweeking of the web.config file
Deleting the entire application and recreating it in azure
I set customerrors mode=off and I received this error: "There is already an open DataReader associated with this Command which must be closed first." Just to be sure I double checked my connection string and MARS is active. Maybe the loop is the issue?
Upvotes: 2
Views: 790
Reputation: 31
Found the issue and how to resolve. Working with the azure support desk, I found that the azure web app architecture didn't support the json events to fullcalendar. I converted this application to a cloud app by downloading the Azure SDK and following the procedures here:
Now that the app is running on a VM, everything works fine. I didn't have to change any coding in the above example.
Upvotes: 1