Copied to clipboard

Flag this post as spam?

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


  • Damien Holley 179 posts 540 karma points
    Jan 10, 2022 @ 01:54
    Damien Holley
    0

    WebAPI Controllers in separate project

    Hi, I have been trying to work with creating a webapi controller in a project separate to the main Umbraco project.

    Does anyone know of any information or tutorials on doing this in umb9? I have tried including the libraries from umbraco.cms.core but it doesn't seem to be working.

  • Søren Gregersen 441 posts 1884 karma points MVP 2x c-trib
    Jan 10, 2022 @ 09:11
    Søren Gregersen
    0

    Hi Damien,

    There should not be any need to do this - just create the controller in your webproject.

    Depending on what issues you are facing, you may need other references. In your project file, you should have the following reference:

    <PackageReference Include="Umbraco.Cms.Core" Version="9.0.0" />
    

    If the api is for backoffice, you may also need

    <PackageReference Include="Umbraco.Cms.Web.BackOffice" Version="9.0.0" />
    

    Adding the libraries, should be done through packages (as per above) to ensure all dependencies are fulfilled.

    HTH :)

  • Damien Holley 179 posts 540 karma points
    Jan 10, 2022 @ 13:36
    Damien Holley
    0

    Yeah I always use nuget packages, the controller I wanted in my project was so I could just package it all up into a nuget package to use internally without having to create a controller every time.

    Otherwise I guess I would have to create the dll then create an umbraco package that can include the controller/plugin.

    Is there a way of using the CropUrl function in a separate project? I don't want to bother with the individual settings, but grab the entire cropped image url with the crop data to supply the api.

Please Sign in or register to post replies

Write your reply to:

Draft