Something like that:
[WebGet(UriTemplate="{id}.ics")]
[OperationContract]
Stream GetCalendar(int id)
{
WebOperationContext.Current.OutgoingResponse.ContentType="text/calendar";
}
So now you can do an HTTP GET, for example. yourService.svc / 123.ics and return iCal.
The reason for this is that "Stream" has a special wrapper in WCF REST (used for non-XML, non-JSON responses).
Remember that for this you need to use the behavior of WebHttpBinding and WebHttp.
source
share