Once you define hostnames for a Content node in Umbraco CMS in the back office – it’s easy to get the list in C# within a few lines of code.
To do so you should use the IDomainService and grab the instance.
private readonly IDomainService _domainService;
You can get service instance using static service locator as follows:
_domainService = Current.Factory.GetInstance<IDomainService>();
The IDomainService has a very easy-to-use method named GetAssignedDomains that returns a list of domains for a given node id.
var domains = _domainService.GetAssignedDomains(1501, includeWildcards: true);