I have the following code snippet:
string tmp = String.Format(\"
You can also use the properties of URIBuilder for this, it has properties for outputting an url the way you want
UriBuilder u1 = new UriBuilder( "http://www.example.com:80/dir/?query=test" );
u1.Port = -1;
string clean = u1.Uri.ToString();
Setting the Port
property to -1
on UriBuilder
will remove any explicit port and implicitly use the default port value for the protocol scheme.