asp.net-mvc – 谷歌日历无法读取ICalendar.

前端之家收集整理的这篇文章主要介绍了asp.net-mvc – 谷歌日历无法读取ICalendar.前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
操作系统:WinXP
您用于访问Google日历的程序和版本(FF3.5):

我正在开发一个脚本(基于我在网上找到的现有vCal ASP.NET类)来生成.ics文件.导入到Outlook 2003时,此文件可以正常工作.当我尝试导入到Google日历时,出现以下错误

无法导入事件:无法处理您的iCal / CSV文件..

我不太了解vCal格式或语法,但一切看起来都不错.我将在下面发布示例测试日历.ics:

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

生成上面代码的源代码就是mvc视图::

<%@ 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

解决方法

ical Feed的问题在于,不同的日历对于不同的东西都很挑剔,而且至少在我看来,这个规范有点难以理解.但是,Kanzaki在为像我这样的程序员制定规范方面做得很好.

现在,你的Feed Feed还需要精确到换行符(Apple的不会导入最后错误的换行符)并且我发现这3个验证器的组合效果最好:

>最基本的:http://severinghaus.org/projects/icv/?url=
>更好:http://icalvalid.cloudapp.net/Default.aspx
>最严格:http://ical-validator.herokuapp.com/validate/

最严格的验证器实际上对我有误报(即,它根据规范报告了实际上没有错误错误),但是前两个没有发现错误,这就是为什么我建议通过所有三个运行您的Feed他们

猜你在找的asp.Net相关文章