Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martin Griffiths 826 posts 1269 karma points c-trib
    Sep 17, 2014 @ 18:09
    Martin Griffiths
    0

    Cultures and hostnames API/Event in Umbraco 7

    Does anyone know if there is an API or Event for the "Cultures and hostnames" dialog in Umbraco 7s back office?

    What I want to do is add the hostname entry to the bindings section in IIS programatically when someone saves a hostname in Umbraco. Which will remove the need to do it manually in an RDP session.

    Thanks in advance

    Martin

  • Dan Lister 416 posts 1974 karma points c-trib
    Sep 18, 2014 @ 10:58
    Dan Lister
    1

    Hi Martin,

    This should do the trick I think:

    umbraco.cms.businesslogic.web.Domain.New += delegate(Domain sender, NewEventArgs args)
    {
        // Add binding to IIS
    };
    

    There are a couple more events on the Domain class too like AfterSave and BeforeSave which might come in handy.

    Thanks, Dan.

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Sep 18, 2014 @ 11:01
    Martin Griffiths
    0

    Dan that looks awesome! Where do I implement it? Can it go straight into a class of my choosing, or will it need to be raised in the application event handler?

    Kind regards

    Martin

  • Dan Lister 416 posts 1974 karma points c-trib
    Sep 18, 2014 @ 11:05
    Dan Lister
    1

    Hi Martin,

    You could probably create a new ApplicationEventHandler class which setups up the event delegate when the application has started:

    using umbraco.cms.businesslogic;
    using umbraco.cms.businesslogic.web;
    using Umbraco.Core;
    
    namespace Application
    {
        public class ApplicationStartup : ApplicationEventHandler
        {
            protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
                umbraco.cms.businesslogic.web.Domain.New += delegate(Domain sender, NewEventArgs args)
                {
                    // Add binding to IIS
                };
            }
        }
    }
    

    Thanks, Dan.

Please Sign in or register to post replies

Write your reply to:

Draft