Reading hosts information on a muti-site CMS install?

I am making a pluigin for Umb17 and need to do a few things with the host information but have no idea where to even start looking. Here is what I need to look for:

1: On site warm up: discover all domains assigned to any nodes in the “Culture and Hostnames” interface.

2: While runinng: if a domain is Added/Updated/Deleted from a node my package needs to know about it.

Can anyone help me figure out where to start on these? Thanks

Hi Matthew!
You’re able to query the Culture and Hostnames via the localizationService found in this documentation

As for your second question, there are notifications for Language and Dictionary items which is how you would track those sort of events. You can find a list of these notification handlers in this documentation.

Hope this all helps!

Thanks but I don’t think that is right. I am not looking for the languages, I am looking for the domain URLs. I don’t care about the languages.

Hi @Eaglef90

For this you can use the IDomainService.

On warm-up, inject it and call GetAll(true) to get every domain across all nodes. Run it from a UmbracoApplicationStartingNotification handler to build your initial list.

While running, subscribe to the domain notifications, DomainSavedNotification and DomainDeletedNotification to get added/updated and deleted domains.

I hope that helps.

Justin

Thanks I will look into those.

One thing I wanted to check on too. How does Umbraco know the domain name if none are set in the hosts config? I.E. it is just a single site setup and the user never goes sets the domain? Does Umbraco just default to server the files on what ever TLD is associated with the incoming request?

Hi @Eaglef90

Yes, I believe that’s the case - it will use the domain and port from the incoming request if no hostnames are specified in the CMS.

Justin

don’t forget the domainCache.. if you don’t have to go to the Service and the DB.. :slight_smile:

Umbraco-CMS/src/Umbraco.PublishedCache.HybridCache/DomainCache.cs at main · umbraco/Umbraco-CMS