Reputation: 1125
I'm trying tu use System.Uri to strip off various information.
E.g. it gets me Uri.Authority.
When my URI is http://some.domain:52146/something, Uri.Authority.ToString() gives me "some.domain:52146".
I'd rather have "some.domain" and the port with a separate call.
Any ideas whow I could strip off the :port_number stuff most elegantly, either with a Uri-method I don't know of or with some string manipulation?
And getting back the http:// would also be useful (to know for example whether it's http or https).
Upvotes: 0
Views: 704
Reputation: 1125
Since I learnt about the properties Uri.Host
and Uri.Port
now I know that Uri.Scheme
gives me the protocol.
Upvotes: 0
Reputation: 460138
Use Uri.Host
and Uri.Port
:
Uri uri = new Uri("http://some.domain:52146/something");
string host = uri.Host; // some.domain
int port = uri.Port; // 52146
Upvotes: 4