.net, programming

Get the root part of a domain in .NET

Need to get the .com, .us, .biz, etc. part of the domain name in .NET?

Here’s how:

Dim root As String
root = Right(Request.Url.Host, (Request.Url.Host.Length) - InStrRev(Request.Url.Host, "."))
Tagged , , ,

2 thoughts on “Get the root part of a domain in .NET

  1. This would work too:

    Dim root as string = replace(right(request.servervariables(“http_host”),3),”.”,””)

Leave a Reply

Your email address will not be published. Required fields are marked *