How to obtain the subdomain of a domain name using VB.NET:
I thought that the System.Uri class contained that information in an easy retrievable way, but no.
Here’s what I came up with instead. It still uses the System.Uri to find the subdomain.
Function GetSubdomain() As String Dim url As Uri = Request.Url Dim host As String = url.Host If host.Split(".").Length > 1 Then Dim index As Integer = host.IndexOf(".") Return host.Substring(0, index) End If Return "" End Function