Copied to clipboard

Flag this post as spam?

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


  • J 445 posts 862 karma points
    Dec 07, 2019 @ 14:22
    J
    0

    Possible to separate the Controller from an Umbraco site?

    Usually i would create a Controller under the controller folder.

    Is there a recommended way to have this reside in a Class Library rather than the Umbraco project?

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Dec 07, 2019 @ 15:10
    Kevin Jump
    0

    Hi J

    Yes, you can create your controllers in a library project rather than the main Umbraco one if you wish.

    I would add a new class library (.net framework) project to my solution, and then if you install the Umbraco.Core package via NuGet into that class library then you can create your controller there and still have access to all the Umbraco base classes.

    install-package UmbracoCms.Core -version 7.15.3 
    

    (for Umbraco 8 you will probably need to install the Umbraco.Web project as this has most of the front end stuff in it)

    just remember to add your class library as a reference to your web project so the DLL gets copied over at build time*

    *because I would never forget to do that, oh no not me.

Please Sign in or register to post replies

Write your reply to:

Draft