URL split in C#?

asp.net, c#

Solution

If you make a System.Uri object from your string, it will have several properties for different parts of the path:

string path = "http://example.com/page?a=1&ret=/user/page2";
Uri uri = new Uri(path);
Console.WriteLine(uri.AbsolutePath); // Prints "/page"

Problem

I have a url like `example.com/page?a=1&ret=/user/page2`. I was using string.split('/') to figure out the paths but this case you can see it isn't very useful. How do i split the URL so i can get the page path?

Original source

Related problems