【发布时间】:2010-05-19 07:44:40
【问题描述】:
我正在构建一个 ASP 站点,我在其中使用 response.write 创建一个 ics 文件,用户可以在其中选择打开或保存事件对话框。当用户选择打开时,Outlook 有时会给出错误“文件 [].ics”不是有效的 Internet 日历文件”。写入响应的始终是同一个事件。代码如下所示:
this.Response.ContentType = "text/calendar";
this.Response.AddHeader("Cache-Control", "no-cache, must-revalidate");
this.Response.AddHeader("Pragma", "no-cache");
this.Response.Expires = -1;
this.Response.AddHeader("Content-disposition", string.Format("attachment; filename={0}.ics",filename));
this.Response.Write("BEGIN:VCALENDAR");
this.Response.Write("\nVERSION:2.0");
this.Response.Write("\nMETHOD:PUBLISH");
this.Response.Write("\nBEGIN:VEVENT");
this.Response.Write("\nType:Single Meeting");
this.Response.Write("\nORGANIZER:MAILTO:" + organizer);
this.Response.Write("\nDTSTART:" + startDate.ToUniversalTime().ToString(DateFormat));
this.Response.Write("\nDTEND:" + endDate.ToUniversalTime().ToString(DateFormat));
this.Response.Write("\nLOCATION:" + location);
this.Response.Write("\nUID:" + Guid.NewGuid().ToString());
this.Response.Write("\nDTSTAMP:" + DateTime.Now.ToUniversalTime().ToString(DateFormat));
this.Response.Write("\nSUMMARY:" + summary);
this.Response.Write("\nDESCRIPTION:" + description);
this.Response.Write("\nPRIORITY:5");
this.Response.Write("\nCLASS:PUBLIC");
this.Response.Write("\nEND:VEVENT");
this.Response.Write("\nEND:VCALENDAR");
this.Response.End();
我第一次尝试在 Outlook 中打开事件时通常会收到错误,第二次它可以正常工作。
有人知道如何解决这个问题吗?
【问题讨论】:
标签: asp.net response outlook-2007 icalendar