我正在尝试为 Google 日历提供由 IIS (ASP.NET) 提供的 Url 日历

I am trying to provide Google Calendar with Url of Calendar served By IIS (ASP.NET)

当我将 .ics 文件放在站点的文件夹中并使用它时,URL Google 识别并可视化它,但是当我尝试通过操作提供文件时 google什么都不做。

这就是我目前所拥有的:

        [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");
    }

.ics 文件如下所示

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

我不知道该怎么做? 是因为它通过来自服务器的 FTP 和来自控制器操作的 HTTP 提供服务吗?

编辑

我在 'Add Other Calendars' 按钮上使用 'From Url' 选项

我们将不胜感激。

解决方案

    [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;
    }