Ropardo Sowftware development company

Experience software development with ROPARDO S.R.L.

RSS Feed
RSS Feed
  • Home
  • About ROPARDO S.R.L
  • Our websites

Generate iCalendar feed from ASP.NET

In order to feed calendar clients (like MS Outlook, Google Calendar) it is required to supply a plain text file with the ‘.ics’ extension.

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//WPCS/iManagement//..//EN
BEGIN:VEVENT
UID:7264
DTSTAMP:20090917T152000Z
SUMMARY:(16:00-17:00)iFinance pilot - kick off
CLASS:PUBLIC
DESCRIPTION:kick off meeting
CATEGORIES:IMANAGEMENT - PROJECTS
LOCATION:
STATUS:CONFIRMED
PRIORITY:1
DTSTART:20090917T160000
DTEND:20090917T170000
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR

One approach is to generate the iCalendar data using the code behind of a regular .aspx page. The key part in this case is to inform the ASP processor how to handle the page: instead of displaying just text, will pass it off to the operating system. These two lines can be placed in the Page_Load event:

Response.AddHeader("content-disposition", "attachment; filename=WorkAheadFeed.ics");
Response.ContentType = "text/calendar;method=request;charset=UTF-8;component=vevent";

As an alternative – if the performance is an issue – one can use a WebHandler (.ashx file), being known that the output is not intended for a browser.
In this case will have to include the IsReusable property and place the code behind logic in the ProcessRequest() which will be invoked whenever the file is requested.

A simple feed will look like this:

   DateTime datStart = DateTime.Now.AddDays(5);
   DateTime datEnd = datStart.AddMinutes(60);
   string strLocation = "Big office";
   string strSummary = "(16:00-17:00)iFinance pilot - kick off";
   string strDescription = "kick off meeting";
 
	public static string GetFormatedDate(DateTime date)
	{
		return date.ToString("yyyyMMdd");
	}
	public static string GetFormattedTime(DateTime date, bool bUTC)
	{
		return date.ToString("HHmm") + (bUTC ? "00Z" : "00");
	}
   Response.Write("BEGIN:VCALENDAR");
   Response.Write("\nVERSION:2.0");
   Response.Write("\nPRODID:-//WPCS/iManagement//..//EN");
   Response.Write("\nBEGIN:VEVENT");
   Response.Write("\nUID:7264");
   Response.Write("\nDTSTAMP:" + GetFormatedDate(DateTime.Now) + "T" + GetFormattedTime(DateTime.Now, true));
   Response.Write("\nSUMMARY:" + strSummary);
   Response.Write("\nCLASS:PUBLIC");
   Response.Write("\nDESCRIPTION:" + strDescription);
   Response.Write("\nCATEGORIES:IMANAGEMENT - PROJECTS");
   Response.Write("\nLOCATION:" + strLocation);
   Response.Write("\nSTATUS:CONFIRMED");
   Response.Write("\nPRIORITY:1");
   Response.Write("\nDTSTART:" + GetFormatedDate(datStart) + "T" + GetFormattedTime(datStart, false)));
   Response.Write("\nDTEND:" + GetFormatedDate(datEnd) + "T" + GetFormattedTime(datEnd, false)));
   Response.Write("\nTRANSP:OPAQUE");
   Response.Write("\nEND:VEVENT");
   Response.Write("\nEND:VCALENDAR");



For complete iCalendar specification see following:

iCalendar Specification Excerpts
Internet Calendaring and Scheduling Core Object Specification

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Get Shareaholic
Tags: ASP.NET feed iCalendar WebHandler

 Posted in: Microsoft.NET
September 17, 2009 | Daniel Bozdoc | No Comments

Leave a Reply

 


  • « Previous post
  • Next post »
  • Recent Posts

    • Installing PyGraphviz on Windows
    • Convert python object to XML representation
    • Liferay Portlet Development
    • Norway Road Show 2011 private meeting invitation
    • Oracle OpenWorld 2011
  • Ropardo is Hiring

  • Subscribe

    • Add to Google Reader or Homepage Add to netvibes TopOfBlogs
  • Recent Comments

    • Rajkumar Pomaji on Bluetooth PC Remote Control
    • Stelian Morariu on GWT 2.1 – Uploading a file using the RPC mechanism
    • Sergio on GWT 2.1 – Uploading a file using the RPC mechanism
    • Artem on Liferay: Deployment will start in a few seconds… and how to realy start
    • rkd80 on GWT 2.1 – Uploading a file using the RPC mechanism
  • Archives

    • November 2011 (1)
    • September 2011 (4)
    • July 2011 (3)
    • June 2011 (2)
    • May 2011 (4)
    • April 2011 (4)
    • March 2011 (3)
    • February 2011 (2)
    • January 2011 (2)
    • December 2010 (1)
    • November 2010 (4)
    • October 2010 (4)
    • August 2010 (3)
    • July 2010 (3)
    • June 2010 (6)
    • May 2010 (8)
    • April 2010 (7)
    • March 2010 (9)
    • February 2010 (6)
    • January 2010 (5)
    • December 2009 (7)
    • November 2009 (9)
    • October 2009 (10)
    • September 2009 (14)
    • August 2009 (10)
    • July 2009 (1)
    • June 2009 (1)
    • May 2009 (1)
    • April 2009 (1)
    • March 2009 (1)
    • October 2008 (3)
    • October 2007 (3)
    • July 2007 (4)
    • June 2007 (1)
    • May 2007 (3)
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
  • Categories

    • News (15)
    • Ropardo Team (8)
    • Ropardo Products (6)
      • File Tracking Client (4)
      • iManagement (2)
    • Software Development (83)
      • Microsoft.NET (22)
      • Java (40)
      • Oracle (8)
      • Power Builder (3)
      • Liferay (5)
      • Lotus Notes (9)
      • xWiki (4)
    • System Adminstration (13)
      • Linux (10)
      • Windows (3)
    • Programming (1)
    • Uncategorized (3)
    • Databases (10)
      • MSSQL (5)
      • PostgreeSQL (3)
    • Microsoft.NET (1)
    • Web Development (28)
      • ASP/ASPX (3)
      • Content Management Systems (1)
      • HTML/CSS (5)
      • Javascrip/AJAX (8)
      • PHP (7)
    • Oracle E Business Suite (6)
  • Tags

    .NET ajax blog C# certification client CMS control css database Debugging django Domino Eclipse extension file tracking filter fun gentoo google Hibernate how to html image iManagement import Java javascript jQuery liferay Linux Lotus Notes lotus script Oracle Oracle BI Publisher 11g PHP portal PostgreSQL powerbuilder Python SQL Telerik velocity xml Xwiki

© 2010 ROPARDO s.r.l..

Powered by WordPress. Styled by Ropardo