When i put the .ics file in a folder of the site and use it's URL Google recognize it and visualize it as well, but when i try to serve the file Via Action google does not do anything.
Thats what i have so far:
[AllowAnonymous]
public FileResult Test()
{
byte[] calendarBytes = Encoding.UTF8.GetBytes(System.IO.File.ReadAllText(@"<filename>", Encoding.UTF8));
var cd = new System.Net.Mime.ContentDisposition
{
FileName = "Test.ics",
Inline = true,
};
Response.AppendHeader("Content-Disposition", cd.ToString());
return File(calendarBytes, "text/calendar");
}
The .ics file looks like this
BEGIN:VCALENDAR
PRODID:eTemida
VERSION:2.0
CALSCALE:GREGORIAN
X-WR-CALNAME:eTemida_Web
METHOD:PUBLISH
X-WR-TIMEZONE:Europe/Sofia
BEGIN:VEVENT
DTSTART:20180301T140000Z
DTEND:20180301T143000Z
DTSTAMP:20180228T145800Z
UID:9358d70d-d1bf-45ea-8f40-321be757dda6
CREATED:20180228T145600Z
DESCRIPTION:eTemida
LASTMODIFIED:20180228T145600Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:eTemida
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART:20180302T123000Z
DTEND:20180302T130000Z
DTSTAMP:20180228T145800Z
UID:9cdd0d9e-891c-4b33-ada8-cf4c7b50b479
CREATED:20180228T145700Z
DESCRIPTION:eTemida
LASTMODIFIED:20180228T145700Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:eTemida
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART:20180302T140000Z
DTEND:20180302T143000Z
DTSTAMP:20180228T145800Z
UID:be32b65f-7435-4544-8c58-8068f8847345
CREATED:20180228T145700Z
DESCRIPTION:eTemida
LASTMODIFIED:20180228T145700Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:eTemida
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR
I dont have any hint about what to do ? Is it because its served via FTP from the server and via HTTP from the Controller's Action ?
EDIT
I'm using 'From Url' option on 'Add Other Calendars' button
Any help will be appreciated.
SOLUTION
[AllowAnonymous]
[HttpGet]
public HttpResponseMessage GetCalendar()
{
string IcsFileData = EventsManager.GenerateCalendarString();
var result = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(IcsFileData)
};
result.Content.Headers.ContentDisposition =
new ContentDispositionHeaderValue("inline")
{
FileName = "Calendar.ics"
};
result.Content.Headers.ContentType =
new MediaTypeHeaderValue("text/calendar");
return result;
}