Skip to content

Instantly share code, notes, and snippets.

@pedroadaodev
Created June 22, 2018 17:26
Show Gist options
  • Save pedroadaodev/6270efb781904085ccc36348d23a244a to your computer and use it in GitHub Desktop.
Save pedroadaodev/6270efb781904085ccc36348d23a244a to your computer and use it in GitHub Desktop.
UmbracoApiController custom routes
using System.Web.Http;
[RoutePrefix("api/store")]
public class StoreController : Umbraco.Web.WebApi.UmbracoApiController
{
[HttpGet]
[Route("")]
public List<StoreModel> GetAll()
{
return StoreManager.GetAll();
}
}
public class UmbracoApplicationEventHandler : IApplicationEventHandler
{
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
WebApiConfig.Register(GlobalConfiguration.Configuration);
}
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
}
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment