Copied to clipboard

Flag this post as spam?

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


  • Funka! 398 posts 661 karma points
    Jun 08, 2013 @ 00:06
    Funka!
    0

    SurfaceControllers: I don't get it...

    I have read the documentation page on these about a dozen times now, searched these forums high and low, and even searching now the web at large, but can't figure it out. (Umbraco version 6.1.1)

    I created a file in my App_Code folder called TestController.cs. Here's the code:

    using System.Web.Mvc;
    namespace DUH.TestSite
    {
        public class TestSurfaceController : Umbraco.Web.Mvc.SurfaceController
        {
            public ActionResult Index()
            {
                //throw new Exception("duh");
                return Content("Yo, this is my test!");
            }
        }
    }

    So... Why can't I surf to this page? I've tried http://testsite.local/test/, http://testsite.local/test/Index, http://testsite.local/umbraco/surface/test/, http://testsite.local/umbraco/surface/test/index, and all kinds of variations. (I have directory URLs enabled, but even tried these all with .aspx extensions.)

    I keep getting 404's.

    So what's the purpose of the surface controller? Is it only for accepting Posts?

    Thank you.

  • Owen 123 posts 246 karma points
    Jun 08, 2013 @ 06:13
    Owen
    100

    The correct url should be:

    http://testsite.local/umbraco/surface/testsurface

    The controller name is "TestSurface" not "Test"

  • Funka! 398 posts 661 karma points
    Jun 11, 2013 @ 23:07
    Funka!
    0

    Owen, thank you! Yes that works and I can see my test message.

    (I suppose I found the documentation page confusing, which says "The controller's name must be suffixed with the term 'SurfaceController'" --- and then later when it describes the routing as needing to include the {controllername}, it did not occur to me that the word "surface" should be part of the controller name, per the earlier note.)

    However: Bummer about this URL though. I certainly wouldn't want this exposed as anything public, would rather just show something like /test.

    So I was about to say that I guess I'm still not really clear on the concept of what good these are, although thinking about it a bit more I suppose they may be marginally useful for [ChildActionOnly] actions or if you don't care about the URL endpoint naming. In any case, thank you for the help and I may have answered my own question here. Hopefully this proves useful to someone else with this same question or can spark further discussion if I've missed anything here.

    Thank you!

Please Sign in or register to post replies

Write your reply to:

Draft