I am trying to get the values of a string
containing a url with a QueryString
.
This is an example of the URL:
string url = "http://example.com?id=gdjh48vnnnvwsid1dkif84ndn?id2=cjodfnuvbvmf47747";
As you can see, it is a string
and not a QueryString
since it is not the address of the page where I am, but a url that I get with a HTTPRequest
.
I would like to know if there is any way to parse and obtain the values of the url (in this case id1
and id2
) without using Split
, Replace
, etc... since this is not a guarantee that it will work 100% of the time (in the value of id1
, for example, appears id1
).
You can use the ParseQueryString method of the HttpUtility class.
Remember that you will need to add a reference to the System.Web assembly if you don't already have it in your project.