locked
how to remove parameter from url RRS feed

  • Question

  • User-1634604574 posted

    i want to remove first parameter from url how can i do it

    Thursday, February 14, 2019 10:07 AM

All replies

  • User-2054057000 posted

    You can simply change the URL in your browser by JavaScript:

    window.history.pushState('page2', 'Title', '/newURL.html');

    Check this tutorial for more info - 7 Common Web Development problems

    .

    Thursday, February 14, 2019 10:31 AM
  • User36583972 posted

    i want to remove first parameter from url how can i do it


    Hi friend,

    You may can try the following methods.

             var stri= RemoveQueryStringByKey("https://www.google.co.uk/search?hl=en&output=search&sclient=psy-ab&removeparamter=cookie", "removeparamter");
    
            public static string RemoveQueryStringByKey(string url, string key)
            {
                var uri = new Uri(url);
                // this gets all the query string key value pairs as a collection
                var newQueryString = HttpUtility.ParseQueryString(uri.Query);
                // this removes the key if exists
                newQueryString.Remove(key);
                // this gets the page path from root without QueryString
                string pagePathWithoutQueryString = uri.GetLeftPart(UriPartial.Path);
                return newQueryString.Count > 0
                    ? String.Format("{0}?{1}", pagePathWithoutQueryString, newQueryString)
                    : pagePathWithoutQueryString;
            }

    If I have any misunderstanding, you can include all necessary code snippets for anyone else to be able to reproduce your issue from scratch along with a detailed description about the results including any exception messages.


    Best Regards,

    Yong Lu

    Friday, February 15, 2019 7:20 AM