This question has answer in other languages/platforms but I couldn\'t find a robust solution in C#. Here I\'m looking for the part of URL which we use in
The closest you could get is the System.Uri.Host property, which would extract the sub1.xyz.com portion. Unfortunately, it's hard to know what exactly is the "toplevel" portion of the host (e.g. sub1.foo.co.uk versus sub1.xyz.com)