将 ICalendar 事件发送到客户端,同时仍然继续运行您的代码

发布于 2024-09-28 21:44:23 字数 536 浏览 0 评论 0原文

我使用 DDay.iCal 构建了一个基本日历事件,当我单击“添加到日历”链接时,我会生成一个事件,然后将其发送给客户端。

基本上,我的应用程序是这样工作的。

  1. 用户登录。
  2. 选择特定日期。
  3. 预订特定时间段
  4. 单击“添加到日历”链接

发送事件是通过使用 Response.Write() 完成的,它将以下内容发送给客户端:

Response.ContentType = "text/calendar";
Response.AddHeader("Content-disposition", "attachment; filename=appointment.ics");
Response.Write(iCalString);

上面的工作正常,但需要我先预订然后手动添加该事件,然后单击“添加到日历”链接。

我想合并步骤 3 和 4。但是当尝试这样做时,活动预订会保存到数据库中,但屏幕不会刷新。

有没有一种“简单”的方法来解决这个问题?

I have built a basic calendar event using DDay.iCal, when I click "Add to calendar" link I produce an event and then sends this to the client.

Basically, my application works like this.

  1. A User logs in.
  2. Selects a specific date.
  3. Books a specific timeslot
  4. Clicks the "Add to calendar" link

Sending the event is done by using Response.Write() which sends the following to the client:

Response.ContentType = "text/calendar";
Response.AddHeader("Content-disposition", "attachment; filename=appointment.ics");
Response.Write(iCalString);

The above works fins but it requires me to first book the event then manually and then click the "Add to calendar" link.

I want to merge the steps 3 and 4. But when trying to do so the event booking gets saved to the database but the screen does not get refreshed.

Is there a "simple" way to get around this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

醉殇 2024-10-05 21:44:23

您需要设置一个简单的 HttpHandler 来发布回复,然后对其执行 Response.Redirect() 。

我之前做过类似的工作,将 vcard 格式集成到网站的人员部分。这些文章应该告诉您设置 HttpHandler 所需的一切 - 只需将 vcard 代码替换为您的 ical 代码即可。

当您重定向到 ical 处理程序时,它会立即弹出下载框,您不会被带到一个空白页面,用户会留在同一页面上。

You need to set up a simple HttpHandler to post the reply and then do a Response.Redirect() into it.

I have done similar work before with integrating the vcard format into an our people section of a website. These articles should tell you everything you need to set up the HttpHandler - just replace the vcard code with your ical code.

When you redirect into the ical handler it will just instantly pop up the download box, you wont be taken to an empty page, the user is left on the same page.

2024-10-05 21:44:23

请确保在发送 iCal 响应信息之前清除您的响应 (Response.Clear)。最后,在发出任何其他内容之前结束您的响应 (Response.End)。从最终使用的角度来看,这将产生与使用 HttpHandler 相同的结果,而不会产生任何麻烦。

Make sure that you clear your response (Response.Clear) prior to sending the iCal response information. Finally, end your response (Response.End) before any other content can be emitted. From the end use standpoint this will produce the same result of using an HttpHandler without the hassle.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文