Assume that you have a string that contains the URL and you want to get the parameters from it in C#, You can easily do it using the static ParseQueryString method that is defined in the System.Web.HttpUtility namespace.
How to Get URL Parameters from String in C# ?
Below is a sample code snippet that demonstrates how you can retreive the URL parameters from a C# string/
Uri myUri = new Uri("http://www.coderseditor.com?param1=tutorial¶m2=onlineide"); string param1 = HttpUtility.ParseQueryString(myUri.Query).Get("param1");
The above code snippet will return the value tutorial and will be assigned to the variable param1.
Enter your email address to subscribe to this blog and receive notifications of new posts by email.