C# Code Samples by Patrik

How to Combine URL in C#

There are times when you want to combine two URLs together. This is where the Uri class comes in handy. The Uri class contains the necessary parameters in its constructors, which can be used to combine 2 URLs.

For example, if we need to combine “http://www.domain.com” and “articles/index.html”, we can use the Uri class.  Below is a sample code snippet demonstrating this.

Uri baseUri = new Uri("http://www.domain.com");
Uri combinedUri = new Uri(baseUri, "articles/index.html");

Path Combine of Url in Html

<img src='<%# new Uri(new Uri(Path), Eval("Image")).AbsoluteUri %>' />

Comments

Leave a Comment

All fields are required. Your email address will not be published.