Path.Combine is handy, but is there a similar function in the .NET framework for URLs?
I'm looking for syntax like this:
Url.Combine("http://MyUrl.com/", "/Images/Image.jpg")
which would return:
"http://MyUrl.com/Images/Image.jpg"
Path.Combine is handy, but is there a similar function in the .NET framework for URLs?
I'm looking for syntax like this:
Url.Combine("http://MyUrl.com/", "/Images/Image.jpg")
which would return:
"http://MyUrl.com/Images/Image.jpg"
Use:
It has the benefit of behaving exactly like
Path.Combine
.Use this:
I find the following useful and has the following features :
params
parameter for multiple Url segmentsClass
Tests
I found
UriBuilder
worked really well for this sort of thing:See UriBuilder Class - MSDN for more constructors and documentation.
I have combined all the previous answers:
My generic solution: