I want to use a console application to easily divide a URL from its params so I can URL encode the parameters. Is there a type that makes this simple? Please keep in mind that this is being run outside of a web server.
The URL is of the form
E.G.
string url = "http://sitename/folder1/someweb.dll?RetrieveTestByDateTime?PatientID=1234¶m2=blah blah blah";
So then I can do
string finalUrl = "http://sitename/folder1/someweb.dll?RetriveTestByDateTime?PatientID=" + HttpUtility.UrlEncode(PatientIDValue) + HttpUtility.UrlEncode(param2Value);
Second, is the second ? valid? This data comes from a 3rd party app. Surely this can be accomplished with Regex, but I prefer not to use it as most people on my team do not know regular expressions.
Use the
Uriclass – pass in the stringurlto the constructor and it will parse out the different parts.The query will be in the
Queryproperty and you can reconstruct the URL easily using theScheme,AbsolutePathand the encodedQuery.