Search code examples
asp.net-web-apinancywebcal

How to define a webcal route in NancyFx, Web API, etc?


I have a route in nancy that currently returns an .ics file. But it's an http route and I would like it to be webcal so that devices will know it's a subscription and handle it automatically.

How can I get nancy to respond to a webcal route?


Solution

  • It's simple. Webcal isn't a real protocol.

    When you click a link that's a "webcal://" address, the browser resolves that to an http request, but because it was a "webcal://" address, the browser knows it's a calendar subscription and will try add the subscription to whatever software you have that supports that (for example Outlook).

    So to get this to work, you just need to change the link address from "http://yoursite.com/youricsfile" to "webcal://yoursite.com/youricsfile" and let the browser or device handle the rest!

    EDIT

    More information from wikipedia...

    The Webcal protocol prefix is used to trigger an external protocol handler which is passed the URL of the .ics file rather than being passed the downloaded contents of the file, in much the same way feed is sometimes used to trigger external RSS readers. The idea is that with this protocol prefix the target file should be subscribed to rather than imported into the calendar application as would happen with a simple download.