Created
February 23, 2013 21:17
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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