Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
496 views
in Technique[技术] by (71.8m points)

asp.net mvc - ICalendar not readable by google calendar.

Operating system : WinXP Program and version you use to access Google Calendar (FF3.5):

I'm developing a script (based on an existing vCal ASP.NET class I found online) to generate an .ics file. This file works perfectly when importing to Outlook 2003. When I try to import to Google Calendar, I get the following error:

Failed to import events: Unable to process your iCal/CSV file..

I don't know too much about the vCal format or syntax, but everything looks fine to me. I'll post the sample test calendar .ics below:

BEGIN:VCALENDAR
PRODID:-//jpalm.se//iCalendar example with ASP.NET MVC//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
DTSTART:20100304T000000Z
DTEND:20100304T000000Z
TRANSP:OPAQUE
SEQUENCE:0
UID:7c9d6dd7-41f2-4171-8ae4-35820974efa4

DESCRIPTION:uba:Project20100321:sagar .

SUMMARY:First Milestone
END:VEVENT
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
DTSTART:20100330T230000Z
DTEND:20100330T230000Z
TRANSP:OPAQUE
SEQUENCE:0
UID:8a982519-b99b-429a-8dad-c0f95c50d0e6

DESCRIPTION:uba:Project20100321:imanage2010 pm

SUMMARY:upcoming milestones
END:VEVENT
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
DTSTART:20100329T230000Z
DTEND:20100329T230000Z
TRANSP:OPAQUE
SEQUENCE:0
UID:588750a1-6f10-4b5d-8a51-3f3818024726

DESCRIPTION:uba:Project20100321:sagar .

SUMMARY:test
END:VEVENT
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
DTSTART:20100407T230000Z
DTEND:20100407T230000Z
TRANSP:OPAQUE
SEQUENCE:0
UID:36eaa726-a0a0-40a1-ba7c-09857f8ed006

DESCRIPTION:uba:Project20100321:imanage2010 pm

SUMMARY:Rad apps devs
END:VEVENT
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
DTSTART:20100408T125632Z
DTEND:20100408T125632Z
TRANSP:OPAQUE
SEQUENCE:0
UID:8521ad53-916a-43cc-8eeb-42c1b3d670d3

DESCRIPTION:uba:Project20100321:imanage2010 pm

SUMMARY:this is a test ms
END:VEVENT
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
DTSTART:20100415T125643Z
DTEND:20100415T125643Z
TRANSP:OPAQUE
SEQUENCE:0
UID:e4b295d8-2271-4393-9899-3e9c858f4e8c

DESCRIPTION:uba:Project20100321:imanage2010 pm

SUMMARY:Test msssss
END:VEVENT
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
DTSTART:20100430T055201Z
DTEND:20100430T055201Z
TRANSP:OPAQUE
SEQUENCE:0
UID:1e464698-1064-4cb2-8166-2a843b63ca5a

DESCRIPTION:uba:Project20100321:imanage2010 pm

SUMMARY:this is a new milestones for testing on 30th april
END:VEVENT
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
DTSTART:20100731T093917Z
DTEND:20100731T093917Z
TRANSP:OPAQUE
SEQUENCE:0
UID:5262ef58-73bc-4d66-a207-4e884e249629

DESCRIPTION:uba:Project20100321:imanage2010 pm

SUMMARY:555555555555555555
END:VEVENT
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
DTSTART:20100328T230000Z
DTEND:20100328T230000Z
TRANSP:OPAQUE
SEQUENCE:0
UID:f654262d-714e-41d9-9690-005bb467f8aa

DESCRIPTION:uba:Untitled project:imanage2010 pm

SUMMARY:first milestone
END:VEVENT
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
DTSTART:20100401T095537Z
DTEND:20100401T095537Z
TRANSP:OPAQUE
SEQUENCE:0
UID:3f4a6c16-f460-457d-a281-b4c010958796

DESCRIPTION:uba:ProjectIcal:imanage2010 pm

SUMMARY:new ms ical
END:VEVENT
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
DTSTART:20100331T230000Z
DTEND:20100331T230000Z
TRANSP:OPAQUE
SEQUENCE:0
UID:e5bf28d1-3559-48e9-90f8-2b5233489a13

DESCRIPTION:uba:ProjectIcal:imanage2010 pm

SUMMARY:new ms 2 ical
END:VEVENT
END:VCALENDAR

And the source for generating the above code is which is nothing but the mvc view::

<%@ Import Namespace ="iManageProjectPM.Controllers" %>
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<iCalendar>"%>
BEGIN:VCALENDAR
VERSION:2.0<%if (Model.Events.Count > 1)
             {%>
CALSCALE:GREGORIAN
METHOD:PUBLISH<%}%>
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
<%foreach(var evnt in Model.Events){%>
BEGIN:VEVENT
DTSTART<%=Model.GetTimeString(evnt.StartTime)%>
DTEND<%=Model.GetTimeString(evnt.EndTime)%>
TRANSP:OPAQUE
SEQUENCE:0
UID:<%=evnt.UID%>
DESCRIPTION:<%=evnt.Desc%>
SUMMARY:<%=evnt.Title%>
END:VEVENT<%}%>
END:VCALENDAR
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The problem with ical feeds is that different calendars are picky about different things, and the spec is, at least for me, kind of hard to follow. However, Kanzaki does a great job of making the spec clear for programmers like me.

Now, your ical feed also needs to be exact down to the newline break (Apple's ical won't import feeds with the wrong newline at the end) and I've found a combination of these 3 validators to work best:

The most strict validator actually had false positives for me (ie, it reported errors that actually aren't errors according to the spec), but caught some errors the first two didn't, that's why I would recommend running your feed through all three of them.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...