Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending ICalendar event to client while still continue running your code

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?

like image 634
Magnus Havenro Avatar asked Oct 26 '10 08:10

Magnus Havenro


People also ask

Is iCalendar the same as ICS?

ics format, also known as iCalendar, is a common bond between these and many other calendar applications, and no conversion is required.

How do I create an ICS file with multiple events in Outlook?

Enter all the event's information in the popup, (title, location, time(s), etc.) and click anywhere outside of the popup to save the details. Then, simply drag and drop the newly-created event on to your desktop to automatically create the . ics file.

What is outlook iCalendar?

The Internet Calendaring and Scheduling Core Object Specification (iCalendar) is a media type which allows users to store and exchange calendaring and scheduling information such as events, to-dos, journal entries, and free/busy information.

What is an ICS link?

An ICS file is an iCalendar file. These are plain text files that include calendar event details like a description, beginning and ending times, location, etc. The ICS format is typically used for sending people meeting requests but also a popular means for subscribing to holiday or birthday calendars.


1 Answers

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.

  • http://professionalaspnet.com/archive/2007/09/23/Streaming-a-vCard-on-the-Fly-in-ASP.NET-with-a-Custom-httpHandler.aspx
  • http://weblogs.asp.net/gunnarpeipman/archive/2009/08/09/creating-vcard-with-image-in-net.aspx

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.

like image 109
rtpHarry Avatar answered Nov 15 '22 21:11

rtpHarry