Copied to clipboard

Flag this post as spam?

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


  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Jul 24, 2015 @ 16:13
    Michaƫl Vanbrabandt
    0

    Add current query string to NiceUrl and NiceUrlWithDomain methods

    Is it possible to extend methods of the UmbracoHelper class?

    You have the NiceUrl() and NiceUrlWithDomain() methods, but wouldn't it be better to also add a param to add the current query string in this url?

    I have a page with some filtering and I would like to store this querystring also into the url of the child page. Then on the child page I have a button Return to list which then takes the filtering from the url to show the results based on this filtering.

    In this way the user doesn't need to select all of his filtering again. Now I have fixed this just by taking the string of the NiceUrlWithDomain() method and added the Request.Url.Query at the end.

    But I will need to do this on several locations so maybe there is a better way of doing this?

  • Kevin Jump 2312 posts 14698 karma points MVP 7x c-trib
    Jul 27, 2015 @ 12:14
    Kevin Jump
    0

    Hi,

    you can add your own extensions to UmbracoHelper. you can build a class with the extension methods in them. (put it in the app_code folder)

    public static string UrlAndQueryString(this UmbracoHelper helper, int nodeId, string queryString)
    {
      // codeness
     return helper.NiceUrl(nodeId) + cleanedQueryString;
    }
    

    should do it, but don't just append the query string. that way cross site scripting lies. good browsers do help. but

    http://url.com/?stuffness.'onmouseover='alert(/boo/)' 
    

    is the type of thing people can then embedd in your webpage.

Please Sign in or register to post replies

Write your reply to:

Draft