Copied to clipboard

Flag this post as spam?

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


  • Craig Cronin 304 posts 503 karma points
    Mar 03, 2015 @ 12:09
    Craig Cronin
    0

    Trouble getting CurrentPage in surface controller

    I'm trying all shapes to get access to my current page in my surfacecontroller but no luck...aarrrgghhh. Everything looks correct, but when i place a breakpoint in my English Action current page gives me Cannot find the Umbraco route definition in the route values, the request must be made in the context of an Umbraco request.

    Any help would be appreciated before I stamp on my PC!!!!

    @using (Html.BeginUmbracoForm("LanguageSelect"))
    {


    }

    public ActionResult English()
    {
     var ss = CurrentPage;
     return Redirect(url + "?lang=en-GB");
    }

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 03, 2015 @ 12:22
  • Craig Cronin 304 posts 503 karma points
    Mar 03, 2015 @ 12:39
    Craig Cronin
    0

    Thanks for getting back to Jan,

    I kinda worked it out.  I have two submit buttons within the one form, so have an additional Action

    public ActionResult LanguageSelect(string submitButton)
    {          
    switch (submitButton)
    {
    case "English":
    return RedirectToAction("English", new { currentId = CurrentPage.Id });
    case "Welsh":
    return RedirectToAction("Welsh", new { currentId = CurrentPage.Id });
    default:
    return null;
    }
    }

    It captures CurrentPage at this point but no in the English or Welsh Actions, so I redirect the NodeId on.
    Thanks :)
Please Sign in or register to post replies

Write your reply to:

Draft