.NET 中的双向可更新 iCal 文件
我一直在尝试在 .NET 中创建一个可以与其他设备同步的 iCal 日历。我一直在使用 DDay.iCal 从我的数据对象生成 iCal 事件,到目前为止一切正常。在 Outlook 中,我通过指向生成 ics 文件的 URL 订阅了日历(添加日历 » 从 Internet):
Response.Clear();
Response.ContentType = "text/calendar";
Response.AddHeader("Content-Disposition", "inline; filename=\"Calendar.ics\"");
Response.Write( GenerateCalendar() );
Response.End();
事件已正确导入到日历中;但是,在我尝试过的任何日历软件中,我都无法更新或删除事件。并不是接收删除通知出错;只是所有客户端都将日历视为只读。
我的想法是,通过提供 URL,我可以让 Outlook 或 Google 日历联系我的服务器以删除事件。我对这应该如何工作的整个想法是错误的,还是我只是错过了正确的属性? (或者,也许我按照上面的代码错误地导入了日历,或者错误地分发了日历?)上面的
GenerateCalendar
生成的日历可能如下所示:
BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
PRODID:-//My Company//My App//EN
URL:http://localhost/test/
X-WR-CALNAME:Test
BEGIN:VEVENT
DTEND:20110831T100100
DTSTAMP:20111028T091109
DTSTART:20110831T090100
SEQUENCE:0
SUMMARY:Test
UID:1
URL:http://localhost/test/?id=1
END:VEVENT
END:VCALENDAR
I've been trying to create an iCal calendar in .NET that can be synced with other devices. I've been using DDay.iCal to generate iCal events from my data objects, and so far everything's working fine. From Outlook, I've subscribed to the calendar (Add Calendar » From Internet) by pointing to a URL that generates an ics file:
Response.Clear();
Response.ContentType = "text/calendar";
Response.AddHeader("Content-Disposition", "inline; filename=\"Calendar.ics\"");
Response.Write( GenerateCalendar() );
Response.End();
The events are properly imported into the calendar; however, in any Calendar software I've tried, I have been unable to update or delete events. It's not that there is an error in receiving the delete notification; it's simply that all clients recognize the calendar as read-only.
My idea is that by supplying URLs, I would be able to have Outlook or Google calendar contact my server in order to delete an event. Is my entire idea of how this is supposed to work wrong, or am I just missing out on the proper properties? (Or, perhaps, am I importing the calendar incorrectly, or distributing it incorrectly, as per the code above?)
A calendar generated by GenerateCalendar
above, may look something like this:
BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
PRODID:-//My Company//My App//EN
URL:http://localhost/test/
X-WR-CALNAME:Test
BEGIN:VEVENT
DTEND:20110831T100100
DTSTAMP:20111028T091109
DTSTART:20110831T090100
SEQUENCE:0
SUMMARY:Test
UID:1
URL:http://localhost/test/?id=1
END:VEVENT
END:VCALENDAR
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我的理解是,您需要在 CalDAV 服务器上托管日历 (https://www.rfc -editor.org/rfc/rfc4791)。简单地发布文件 (.ics) 与在日历引擎上托管日历不同。
My understanding is that you need to host your calendar on a CalDAV server (https://www.rfc-editor.org/rfc/rfc4791). Simply publishing a file (.ics) is different from hosting a calendar on a calendar engine.
遇到了完全相同的问题,我通过安装 davmail 服务器并使用 php 通过它发布日历事件来解决它。它可以配置 http 基本身份验证,与 CURL 之类的东西一起使用相对容易。 Davmail 为各种设备提供了很好的文档和设置指南
为了使其真正成为双向方式,您可以只存储用户的凭据信息并使用 crontab 或类似的东西发出请求。
Had the exact same problem and I solved it by installing davmail server and posted calendar events thru it with php. It can be configured with http basic authentication which is relative easy to use with things like CURL. Davmail has nice documentation and setup guides for various devices
To make it really 2-way you can just store credential info of users and make request with crontab or something similar.
我认为您应该能够通过将方法从发布更改为请求并将组织者条目添加到 VEVENT 块来使其工作,即使它是一个虚拟电子邮件地址。
有关更多详细信息,请参阅 RFC 2446
I think that you should be able to get it to work by changing the METHOD from PUBLISH to REQUEST and adding an ORGANIZER entry to the VEVENT block, even if it is a dummy email address.
For more details see RFC 2446
我知道 “IP*Works! Internet Toolkit” 支持对于 WebDav。
I know the "IP*Works! Internet Toolkit" has support for WebDav.