Copied to clipboard

Flag this post as spam?

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


  • DarkCoder 19 posts 39 karma points
    Jun 06, 2013 @ 21:44
    DarkCoder
    0

    How to render action from mastertemplate?

     

    I want to render an action from my master template.

    In my mastertemplate:

    @Html.Action("BoxLogin")

    My Controller called "BoxLoginController":

        public class BoxLoginController : Umbraco.Web.Mvc.SurfaceController
        {
            [HttpGet]
            public ActionResult BoxLogin()
            {
                return PartialView("BoxLogin");
            }
        }

    My BoxLogin view:

    @{
        Layout = null;
    }
    This is my Boxlogin

     

    When I just do this I get an error:

    No route in the route table matches the supplied values.

     

    Ok, so I override the global.asax:

           protected override void OnApplicationStarting(object sender, EventArgs e)
            {
                base.OnApplicationStarting(sender, e);
                RouteTable.Routes.MapRoute(
                    "BoxLogin",                                              // Route name
                    "{controller}/{action}",                           // URL with parameters
                    new { controller = "BoxLogin", action = "BoxLogin" }  // Parameter defaults
                );    
            }

     

    Now My page renders ONLY the BoxLogin and not the HTML in my template...sigh...


    Any tips for me?

     

  • DarkCoder 19 posts 39 karma points
    Jun 06, 2013 @ 22:05
    DarkCoder
    0

    I tried to delete this topic, because it was too noob-like, but this forum is buggy and would not delete it.

    Well as you may notice it was a stupid routing mistake.

    With this route it worked:

    RouteTable.Routes.MapRoute("BoxLogin", "BoxLogin/BoxLogin", new { controller = "BoxLogin", action = "BoxLogin" });

     

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Jun 07, 2013 @ 08:01
    Dave Woestenborghs
    0

    Normally you don't need to map the SurfaceController. Umbraco will do this for you.

    Can you change the call to your action to include the controller like this :

    @Html.Action("BoxLogin","BoxLogin")

  • DarkCoder 19 posts 39 karma points
    Jun 07, 2013 @ 17:52
    DarkCoder
    0

    After the first post I did correct action as you suggest.

    Regarding SurfaceController, I read that when you need to do postbacks then you need to inherrit from that?

    What is SurfaceController used for then?

Please Sign in or register to post replies

Write your reply to:

Draft