Copied to clipboard

Flag this post as spam?

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


  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 28, 2015 @ 18:09
    Martin Griffiths
    1

    UmbracoApiController SurfaceController in separate project

    I have a large project which contains a stack of shared code across many sites. I've now moved this code from each site into a shared MVC project.

    Whilst i've found it trivial to move all of my Views, CSS, scripts and models into this shared project, moving Controllers seems far from trivial.

    Does anyone know how to move UmbracoApiControllers and SurfaceControllers into a seperate "shared" project. Containing nothing more than the core Umbraco dlls? I'm thinking there's issues with routing and registering that requires extra code.

    Thanks in advance

    Martin

  • Richard Terris 273 posts 715 karma points
    Jan 30, 2015 @ 17:50
    Richard Terris
    1

    Hi Martin,

    All you need for an UmbracoApiController is a reference to Umbraco.Web so in theory that's all you need to do this and you'd just have a post build event to copy your project dll to the Umbraco project using it.

    But, I imagine you may be performing logic either in the controller, or in some helper class called by the controller? In which case you may need other references.

    As for routing then you probably don't need to set up any routes but I'm not sure what your controller does.

    Can you give more info on the controller (maybe post some code) and outline what the issues are, or what errors you are getting?

    Richard

  • Stephen O 1 post 72 karma points
    Nov 29, 2019 @ 00:34
    Stephen O
    1

    In case anyone else comes across this, my issue was pretty basic, bu tripped me up for a bit - I hadn't set my API Project as a dependency in my project which has a reference to UmbracoCMS.

    Once I did that, routing worked as expected. So our configuration is as follows:

    API project references:

    • UmbracoCms.Core

    Web project references:

    • UmbracoCms
    • API project
Please Sign in or register to post replies

Write your reply to:

Draft