before writing my own :-)
I was wondering if anyone knows a tool to parse a URL and extract all the params into a easier viewable format, a grid maybe? (these urls are extremely long :- )
And also if it allows you to construct the querystring for standard text and automates the URL ENCODING etc.
Must be one available, i have searched high and low and can't find anything.
Thanks in advance
The ParseQueryString method is pretty handy for those tasks.
I was wondering if anyone knows a tool to parse a URL and extract all the params into a easier viewable format, a grid maybe? (these urls are extremely long :- )
using System;
using System.Web;
class Program
{
static void Main()
{
var uri = new Uri("http://foo.com/?param1=value1¶m2=value2");
var values = HttpUtility.ParseQueryString(uri.Query);
foreach (string key in values.Keys)
{
Console.WriteLine("key: {0}, value: {1}", key, values[key]);
}
}
}
And also if it allows you to construct the querystring for standard text and automates the URL ENCODING etc.
using System;
using System.Web;
class Program
{
static void Main()
{
var values = HttpUtility.ParseQueryString(string.Empty);
values["param1"] = "value1";
values["param2"] = "value2";
var builder = new UriBuilder("http://foo.com");
builder.Query = values.ToString();
var url = builder.ToString();
Console.WriteLine(url);
}
}