Copied to clipboard

Flag this post as spam?

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


  • Sam 26 posts 137 karma points c-trib
    Mar 19, 2015 @ 04:33
    Sam
    0

    Can't pick up surface controller in class library

    Hello,

    I have a fresh Umbraco install (not from nuget).

    I have created a class library with a surface controller and referenced to it from my Umbraco project.

    My surface controller currently just has one method:

    public class PostALetterSurfaceController : SurfaceController
    {
        public ActionResult Post()
        {
            return Content("Test");
        }
    }
    

    I am browsing to my Umbraco instance at : http://localhost/umbraco/surface/PostALetter/Post but I am getting a 404

    Is there anyway to debug if my class library is being picked up by umbraco correctly?

    Thanks, Sam

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 19, 2015 @ 05:18
    Jan Skovgaard
    0

    Hi Sam and welcome to our :)

    How is your project setup? Do you have the VS solution at the same level as your Umbraco website? If so do you then use XCOPY to copy over the DLL's to the /bin folder when you build? I suspect that the assemblies are missing for some reason.

    Looking forward to hearing from you.

    /Jan

  • steve 2 posts 22 karma points
    Mar 19, 2015 @ 12:53
    steve
    0

    Hi there,

    I have a similar problem on fresh empty asp.net 4.5 web application and nuget umbraco install (7.2.2)

    However I have the controller class in the root of the umbraco directory in a Controllers folder.  

    When I try and access it i get a 404 error.

    However if i move it into the app_code folder, i get the following exception...

    ------------------------------------------------------------------------------------------------

    A route named 'umbraco-surface-MySurface

     is already in the route collection. Route names must be unique.

    Parameter name: name

    --------------------------------------------------------

     

     

     

     

     

  • steve 2 posts 22 karma points
    Mar 19, 2015 @ 13:16
    steve
    0

    I managed to figure out the issue myself.

    i had named my controller MySurfaceController (and inheirted form umbraco.web.mvc.surface controller); however the url i was using to attempt to access it was

    /umbraco/surface/My/ 

    and / or

    /umbraco/surface/MySurfaceController/

    however it would be appear that the adive that the controller needs to be suffixed SurfaceController is out of date, when i used the url

    /umbraco/surface/MySurface/

    it worked...

    so from my experience you do not need to suffix with SurfaceController for it to be routed properly however as per asp.net mvc convention it does need to be suffixed with Controller.

    the app_code part was a red herring and i have now deleted that folder from my solution as it is not required within a web application.

    Hope this helps someone else. 

    I am sure the Umbraco Videos site would provide up to date documentation on V7, however although i have purchased a subscription, i cannot login and support have not responded to me yet.   

    thanks, 

    Steve

     

    Steve

     

  • Sam 26 posts 137 karma points c-trib
    Mar 19, 2015 @ 21:57
    Sam
    0

    Thanks Steve, that was it :)

Please Sign in or register to post replies

Write your reply to:

Draft