0

I've created a new ASP.NET MVC 4 app in VS2012. Target is .NET 4.5.

I created a CalendarController ApiController with a single method that returns an HttpResponseMessage with text content that complies with the iCal specification.

I want this method to be served from a URL that looks like this:

http://www.example.com/api/calendar/mycalendar.ics

but I can't create the appropriate routing config to make this happen.

I can get this to work:

http://www.example.com/api/calendar/mycalendar

but I need the .ics extension.

Why do I need the extension you might ask. The answer is that iOS interprets the URL with the .ics extension as a signature of a "subscribed" calendar. Without the extension, it interprets the calendar as a set of events that are copied and does not create a "subscription".

Any help is appreciated

Daniel
  • 8,794
  • 4
  • 48
  • 71
  • 1
    Check http://stackoverflow.com/questions/11728846/dots-in-url-causes-404-with-asp-net-mvc-and-iis?rq=1 – UserControl May 05 '13 at 07:20
  • @UserControl looks like that question's chosen answer worked for me. thanks a bunch for the quick response! Not sure if it screwed up anything else. So I'll roll with for a little while, and follow up with an update to this question. – Daniel May 05 '13 at 07:36

1 Answers1

0

Specifically these two things together are what you need

Ensure your route is defined to have the custom extension on it (.ics)

routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}.ics",
    defaults: new { controller = "Home", action = "Index"}
);

Set the web.config to run every request through your app not just the extensionless uris

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
Adam Tuliper
  • 29,982
  • 4
  • 53
  • 71