Copied to clipboard

Flag this post as spam?

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


  • Marcos 9 posts 30 karma points
    Nov 19, 2012 @ 13:42
    Marcos
    0

    4.10 SurfaceController attribute

    Hi everybody. I'm having some trouble creating a v4.10 plugin. When I try to add SurfaceController attribute to my class, I got the following error: 'Umbraco.Web.Mvc.SurfaceController' is not an attribute class.

     

    Here's my code:

     

    [SurfaceController("Management")]
    public class Prova1Controller : SurfaceController
    {
            [ChildActionOnly]
            public ActionResult Index()
    {

                return Content("Ciao");

            }
        }

    thanks in advance for any help

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Nov 19, 2012 @ 14:04
    Dirk De Grave
    0

    Ok, just a shot in the dark as your error msg is totally unrelated.... From the docs:

    To create a locally declared SurfaceController:

    • Create a controller that inherits from Umbraco.Web.Mvc.SurfaceController
    • The controller must be a 'public' class.
    • The controller's name must be suffixed with the term 'SurfaceController'

    So, your class should be Prova1SurfaceController

    If still the same error msg, I'd log this issue so a core team member can have a look at it.

     

    Cheers,

    /Dir

  • Marcos 9 posts 30 karma points
    Nov 19, 2012 @ 14:09
    Marcos
    0

    Yes, sorry, it was my error. Of course the classname is Prova1SurfaceController. It seems like I'm not having the SurfaceController attribute class in my umbraco.web.mvc namespace...

  • Marcos 9 posts 30 karma points
    Nov 19, 2012 @ 15:05
    Marcos
    0

    Mmmmh. There's something very strange here.

    I'm calling the controller without the class attribute (as a normal SurfaceController).

    When, within a View, I want to call an action like this:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using System.Web.Mvc.Html
     
    @{

        Layout = null;

    }

    Action: @Html.Action("index", "Prova")

    I got this error: " No route in the route table matches the supplied values". But if I call the action giving "ProvaSurface" as the controller name it works...

  • Richard Terris 273 posts 715 karma points
    Nov 27, 2012 @ 11:41
    Richard Terris
    0

    Marcos

    Have you tried using an ActionLink HTML helper?

    @Html.ActionLink("Link Text", "Action Name", "Controller Name")

    So in your case:

    @Html.ActionLink("Click Here", "Index", "Prova1")

  • Richard Terris 273 posts 715 karma points
    Nov 27, 2012 @ 12:13
    Richard Terris
    0

    Having just tried that myself, I think this should work:

    @Html.ActionLink("Click Here", "Index", "Prova1Surface")

  • Marcos 9 posts 30 karma points
    Nov 27, 2012 @ 12:42
    Marcos
    1

    Yes, it works. But I thought that I should refer the controller as just "Prova" and not "ProvaSurface".

     

    Anyway, I still got the ClassAttribute problem, so i cannot make area-separated controllers

  • Richard Terris 273 posts 715 karma points
    Nov 27, 2012 @ 12:49
    Richard Terris
    0

    I thought so too but my controller didn't work until I added the full name, leaving off "controller"

    Not sure about the other issue because I'm not getting it - mine is a fresh install of 4.11; are you on 4.10?

    I'd definitely log the issue, but you might also try the exact same thing in a 4.11 site and see if you can narrow it down?

  • Jonas Eriksson 930 posts 1825 karma points
    Dec 12, 2012 @ 02:38
    Jonas Eriksson
    0

    Hi

    Seems we should use the PluginController attribute instead

    [PluginController("MyArea")]

    http://issues.umbraco.org/issue/U4-702

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies