Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Paul Stoker 39 posts 72 karma points c-trib
    Feb 03, 2015 @ 18:24
    Paul Stoker

    Production issue: How to access API route when ~/umbraco is filtered by IP Address & Domain Restrictions

    Something that has bugged me for a while is that I can't create an Umbraco API Controller that is consumed by say a page in the website since our production environment blocks requests to ~/umbraco.

    If I create a controller that's accessible by the following it's always blocked because it starts with ~/umbraco


    I have tried to create a custom route in the routing table but this doesn't seem to work.

    Can someone tell me if this is possible and how?

  • Richard Terris 273 posts 715 karma points
    Feb 04, 2015 @ 13:14
    Richard Terris


    My suggestion would be using WebApiController instead of UmbracoApiController

    That way your URL would be ~/Api/Controller/Action

    Would that work for you?


  • Paul Stoker 39 posts 72 karma points c-trib
    Feb 04, 2015 @ 16:05
    Paul Stoker

    Hi Richard,

    I didn't think I could use the Umbraco backend this way. Turns out I can :-)

    public class SomeApiController : ApiController
        private readonly UmbracoHelper umbracoHelper;
        public SomeApiController()
            umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
        public IEnumerable<string> GetAll()
            return umbracoHelper.TypedContentAtRoot().Select(p => p.Name);

    And a route in the routing table:

        name: "DefaultApi",
        routeTemplate: "api/{controller}/{id}",
        defaults: new { id = RouteParameter.Optional }


  • Richard Terris 273 posts 715 karma points
    Feb 04, 2015 @ 16:19
    Richard Terris

    Yeah, the UmbracoApiController inherits from ApiController in .NET

    Unless you're using some of the extras in that controller like UmbracoHelper for example, then you can use the standard .NET controller.

    Even if you needed UmbracoHelper you could just instantiate it in your controller anyway.

    Glad that helped.

Please Sign in or register to post replies

Write your reply to: