You can use System.UriBuilder class to build a new well-formed URI. You need to set some property of UriBuilder object’s, like Scheme, Port, Host, Path etc…
You can get generated URI using AbsoluteUri Method.
// Generate a new URI. UriBuilder objUri = new UriBuilder(); objUri.Scheme = "http"; objUri.Port = 80; objUri.Host = "www.microsoft.com"; objUri.Path = "en-us/default.aspx"; Response.Write("Genereted URI: " + objUri.Uri.AbsoluteUri);
Happy coding!