Skip to content

Instantly share code, notes, and snippets.

@jhauge
Created February 23, 2013 21:17
Show Gist options
  • Save jhauge/5021370 to your computer and use it in GitHub Desktop.
Save jhauge/5021370 to your computer and use it in GitHub Desktop.
Setup for using web api controllers in an Umbraco website. Code depends on two nuget packages: Microsoft.AspNet.WebApi and [WebActivator](https://github.com/davidebbo/WebActivator)
// Put this file in /App_Start
using Twins.UmbWebApi.App_Start;
using System.Web.Http;
using System.Web.Routing;
[assembly: WebActivator.PreApplicationStartMethod(typeof (AppStart), "RegisterRoutes")]
namespace YourProject.UmbWebApi.App_Start
{
public class AppStart
{
public static void RegisterRoutes()
{
// Following line is a basic routing registration pointing all web api
// controllers in the project at /umbapi/
RouteTable.Routes.MapHttpRoute("RouteName", "umbapi/{controller}/{id}",
new {id = RouteParameter.Optional});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment