如何在 NancyFx、Web API 等中定义 webcal 路由?

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

我在 nancy 有一条路线,目前 returns 一个 .ics 文件。但它是一个 http 路由,我希望它是 webcal,这样设备就会知道它是一个订阅并自动处理它。

我怎样才能让 nancy 回复 webcal 路由?

很简单。 Webcal 不是真正的协议。

当您单击 link 时,这是一个 "webcal://" 地址,浏览器会将其解析为一个 http 请求,但因为它是一个 "webcal://" 地址,所以浏览器知道它是一个日历订阅并将尝试将订阅添加到您拥有的任何支持该订阅的软件(例如 Outlook)。

因此,要使其正常工作,您只需将 link 地址从 "http://yoursite.com/youricsfile" 更改为 "webcal://yoursite.com/youricsfile",让浏览器或设备处理其余部分!

编辑

更多信息来自 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.