Copied to clipboard

Flag this post as spam?

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


  • Damien Green 72 posts 134 karma points
    Sep 01, 2014 @ 20:44
    Damien Green
    0

    How do api controllers in the App_Plugins directory get routed?

    Hi Guys,

    I'm relatively new to Umbraco (working with V7) and I'm currently extending the backend, creating a custom Image Gallery plugin. As part of this process, I'm writing a custom property editor. All of the files are hosted in the App_Plugins directory. My project includes an API Controller that I also wish to host in the App_Plugins directoty.

    My problem is that I cannot find out how the API Controller is routed or whether I need to manually route it myself. The API controller is called ImageGalleryApiController.cs and it sits in a plugin folder called ImageGallery which sits under the App_Plugins folder.

    Does anyone know how I can find the URL of my API controller, I have tried various things such as:

    http://localhost:500/App_plugins/ImageGallery/imagegalleryapi/getimages?GalleryID=l

    and 

    http://localhost:500/umbraco/App_plugins/ImageGallery/imagegalleryapi/getimages?GalleryID=l

    but neither of these URLs works. I can get it to work if I put the Api Controller in a controllers directory in root of the Umbraco directory tree as indicated by various API controller tutorials, but I want to host my API controller in the App_Plugins folder so I can keep everything together.

    I've done various Google searches and apart from a few suggestions that haven't worked, I haven't turned up anything useful.

    I'm sure this must be possible.

    Thanks,

    Damien.

     

  • Damien Green 72 posts 134 karma points
    Sep 01, 2014 @ 21:05
    Damien Green
    0

    Typically I've just found the answer. For those who also woudl like to know, you basically need to decorate your controller the PluginController attribute to give you something like the following:

    [PluginController("ImageGallery")]

    public class ImageGalleryApiController : UmbracoApiController
    { ....

    The above will cause it to routed to:

    http://yoursite.co.uk/umbraco/ImageGallery/ImageGalleryApi/GetImages - assumning you had a parameterless method called GetImages

    Hope this helps others with a similar question.

    Cheers,

    Damien

Please Sign in or register to post replies

Write your reply to:

Draft