Helping you always. Don't forget to click "Mark as Answer" on the post that helped you.
♠ ASP.NET Core Tutorials → Start from the Beginning and become an Expert in 30 days time ♠
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
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
75 Points
513 Posts
how to remove parameter from url
Feb 14, 2019 10:07 AM|zhyanadil.it@gmail.com|LINK
i want to remove first parameter from url how can i do it
Participant
1253 Points
936 Posts
Re: how to remove parameter from url
Feb 14, 2019 10:31 AM|yogyogi|LINK
You can simply change the URL in your browser by JavaScript:
Check this tutorial for more info - 7 Common Web Development problems
.
♠ ASP.NET Core Tutorials → Start from the Beginning and become an Expert in 30 days time ♠
Star
11464 Points
2439 Posts
Re: how to remove parameter from url
Feb 15, 2019 07:20 AM|Yohann Lu|LINK
Hi friend,
You may can try the following methods.
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