Skip to content

Instantly share code, notes, and snippets.

@nul800sebastiaan
Created February 11, 2013 15:36
Show Gist options
  • Select an option

  • Save nul800sebastiaan/4755162 to your computer and use it in GitHub Desktop.

Select an option

Save nul800sebastiaan/4755162 to your computer and use it in GitHub Desktop.
Register Web API route in Umbraco 6
using System.Linq;
using System.Web.Http;
using System.Web.Routing;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Publishing;
using umbraco.interfaces;
namespace Site.EventHandlers
{
public class StartupEventHandlers : IApplicationStartupHandler
{
public StartupEventHandlers()
{
Umbraco.Web.UmbracoApplication.ApplicationStarting +=
UmbracoApplicationStarting;
}
static void UmbracoApplicationStarting(object sender, System.EventArgs e)
{
RouteTable.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment