Copied to clipboard

Flag this post as spam?

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


  • Berto 105 posts 177 karma points
    Mar 18, 2014 @ 21:58
    Berto
    0

    Hijack umbraco routes and querystring

    Hi,

    We are developing a single page app, and I'm hijaking the routes so that all the pages are correctly rendered with the follwing code:

    [HttpGet] public override ActionResult Index(RenderModel model) {

            //Do some stuff here, the return the base Index method
            var template = ControllerContext.RouteData.Values["action"].ToString();
    
            if (Request.QueryString != null)
            {
                foreach (string item in Request.QueryString.Keys)
                {
                    if (TempData.ContainsKey(item))
                    {
                        TempData.Add(item, Request.QueryString[item]);
                    }
    
                }
    
            }
    
    
    
            if (Request.Headers["custom-ajax-request"] != null || model.Content.DocumentTypeAlias == "HtmlTextPage")
            {
    
                if (model.Content.DocumentTypeAlias == "HomePage")
                {
    
    
                    return View("HomePageAjax", model);
                }
                else
                {
                    return base.Index(model);
                    //return View(template, model);
                }
            }
            else
            {
                var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
                var hp = model.Content.AncestorOrSelf("HomePage");
                return View(hp.GetTemplateAlias(), CreateRenderModel(hp));
            }
        }
    

    But when we make a call with a querystring, this in not available on HttpContext, can someone help me on this?

    Thx!

    Alberto

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Mar 19, 2014 @ 17:28
    Jeroen Breuer
    0

    That's strange. Querystrings should work. Are you doing something special why it might not work?

    Jeroen

  • Berto 105 posts 177 karma points
    Mar 19, 2014 @ 17:35
    Berto
    0

    Yep, the special thing is my stupidity!

    We are using jQuery Address, and instead of using the event.value that has the path and querystring, we used the event.path, that only gives the path...

    Sigh... so many hours lost :D

    Thx!

    Berto

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Mar 19, 2014 @ 17:39
    Jeroen Breuer
    0

    Good old jQuery Address. I've been using it on some websites too and this sounds familiar ;-). Glad you got it fixed :-).

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft