将 ICalendar 事件发送到客户端,同时仍然继续运行您的代码
我使用 DDay.iCal 构建了一个基本日历事件,当我单击“添加到日历”链接时,我会生成一个事件,然后将其发送给客户端。
基本上,我的应用程序是这样工作的。
- 用户登录。
- 选择特定日期。
- 预订特定时间段
- 单击“添加到日历”链接
发送事件是通过使用 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.
- A User logs in.
- Selects a specific date.
- Books a specific timeslot
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要设置一个简单的 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.
请确保在发送 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 anHttpHandler
without the hassle.