Copied to clipboard

Flag this post as spam?

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


  • Ben Grimwade 4 posts 75 karma points
    Nov 03, 2015 @ 19:54
    Ben Grimwade
    0

    SurfaceControllers in exported Packages

    I am trying to create a package of my code in Umbraco 7. Everything works fine when I import the package to a new Umbraco project except that the new project can not find the SurfaceController in the routes table unless I specifically import the file into the Visual Studio project (which my end client won't have).

    I've followed the instructions here: https://our.umbraco.org/documentation/reference/routing/surface-controllers

    But get the same "Could not find route" error.

    I've created an Area under my project called "Controls" and added the controller there. I've then adorned the controller with the [PluginController("Controls")]. So I have this structure:

    --Root VS Project
       --Area
         --Controls
           --Controllers
             --MyController
    

    I call this from my code like so:

    @Html.Action("Index", "MyController", new { area = "Controls" }
    

    This works absolutely fine again when running in VS with these files included as part of the project, but breaks when I then export this and import the package (with all of the other associated files) in to a new Umbraco project, saying that it can't find the route. My assumption was that adding the [PluginController("Controls")] attribute meant that upon startup the Umbraco project would find the controller and add it to the routes. Is this not the case?

  • Ben Grimwade 4 posts 75 karma points
    Nov 05, 2015 @ 20:04
    Ben Grimwade
    1

    The issue was that I wasn't including the DLL of the project from which I was exporting in to the bin folder of the project to which I was importing.

Please Sign in or register to post replies

Write your reply to:

Draft