Copied to clipboard

Flag this post as spam?

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


  • Ayo Adesina 445 posts 1059 karma points
    Sep 29, 2015 @ 11:43
    Ayo Adesina
    0

    Surface Controller Not Routing Correctly

    Hey Guys,

    I have a bit of trouble getting a surface controller to fire correctly.

    public class SocialShareSurfaceController : Umbraco.Web.Mvc.SurfaceController
        {
            public ActionResult Index()
            {
                return Content("hello world");
            }
        }
    

    I'm trying to get to the controller via this URL: http://website.local/umbraco/surface/SocialShare/Index/

    But I am getting 404 error..... If I then move this file to the App_Code folder go to the same URL I get this error

    A route named 'umbraco-surface-SocialShareSurface' is already in the route collection. Route names must be unique. Parameter name: name

    Any Ideas...

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Sep 29, 2015 @ 12:32
    Sebastiaan Janssen
    1

    The route will be http://website.local/umbraco/surface/SocialShareSurface/Index/

    You don't need to put the word "Surface" in the controllername though, just make sure it ends with Controller, so you can rename to SocialShareController and then your controller will work.

    As for the second problem: if you have a dll with this class name and ALSO an App_Code file with the same class name then they will conflict which is why it's telling you route names need to be unique.

  • Ayo Adesina 445 posts 1059 karma points
    Sep 29, 2015 @ 12:54
    Ayo Adesina
    0

    Thank you, thank you thank you, I didn't notice the extra surface bit on the end....working now.

    The app_code thing...still not sure though, even if I rename it to something random it still gives the same error....

    any way thanks - I wish I worked in your office.... I would rape your brain! :-)

    Thanks!

  • Janae Cram 63 posts 439 karma points MVP 8x c-trib
    Sep 29, 2015 @ 14:38
    Janae Cram
    3

    Hey, Ayo :) I just wanted to let you know that I know you don't mean anything bad with the phrase, and it's basically a #h5yr, but I'd personally appreciate it if you'd be careful saying things like "rape your brain" in the future.

    They can really make me, other women, and a lot of people in general really uncomfortable.

    Glad your routing problem got fixed, tho! And thanks for considering my words :)

  • Ayo Adesina 445 posts 1059 karma points
    Sep 29, 2015 @ 16:43
    Ayo Adesina
    1

    Fellow Umbraco Practitioners....

    Sorry Sorry Sorry Sorry....from the bottom of my heart. Typed without thinking, didn't mean anything by it, little bit over excited about surface controllers.

    @Janae - I accept your comments, without reservation, i didn't mean to upset you in any way.

  • Janae Cram 63 posts 439 karma points MVP 8x c-trib
    Sep 29, 2015 @ 21:07
    Janae Cram
    1

    Ayo, I totally understand how it is to get excited in the moment of solving a problem. I'm like that ALL the time :D No worries and thank you so much for being so positive in your response #h5yr

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Sep 29, 2015 @ 19:47
    Niels Hartvig
    0

    Bravo to both Janae and Ayo - thank you both <3

Please Sign in or register to post replies

Write your reply to:

Draft