Copied to clipboard

Flag this post as spam?

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


  • Ed Parry 64 posts 252 karma points c-trib
    Jul 24, 2018 @ 10:14
    Ed Parry
    0

    Setting the UmbracoApplicationUrl programmatically

    Hi all,

    I have a scenario where Umbraco running in a load balanced environment isn't picking up the correct umbracoApplicationUrl at start-up. A work-around here is to use the value in umbracoSettings.config, but our build/deployment process is fully automated, and there's a known bug in VSTS that only allows XML transformations at release time from web.config, but JSON transformations anywhere.

    Because of that, we're looking to see if the umbracoApplicationUrl can be set in code, or the main web.config (without moving the whole settings config into it). The source code doesn't appear to expose a method to set the value, and I'm not sure if the available start-up methods are already too late?

    Does any one know of a method to be able to override the umbracoApplicationUrl programmatically?

    Thanks!

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Jul 25, 2018 @ 00:20
    Marc Goodson
    100

    Hi Ed

    Have a look at the information on Flexible Load Balancing here:

    https://our.umbraco.com/Documentation/Getting-Started/Setup/Server-Setup/Load-Balancing/flexible-advanced

    You can basically take responsibility for determining which servers should be Master or Slave, by implementing your own IServerRegistrar2 implementations (one for master, and one for slave)... and then have an appsetting (which you can transform for different environments) that you read on application startup that determines which server uses which IServerRegistrar2 implementation...

    When you implement an IServerRegistrar2 class you implement a method GetCurrentServerUmbracoApplicationUrl() and it's here you can set programmatically your umbracoApplicationUrl... if you return null, Umbraco will look in UmbracoSettings, and then if not set there, default to the first request the server receives.

    regards

    Marc

  • Ed Parry 64 posts 252 karma points c-trib
    Jul 25, 2018 @ 07:21
    Ed Parry
    0

    Hi Marc,

    That looks to be exactly what we're after - thanks so much! Don't know why I didn't check the flexible load balancing docs first - we followed them to build the initial environments but something in my head told me "forcing" a site URL and "flexible" load balancing just couldn't be on the same page. Mind games!

    Thanks again!

Please Sign in or register to post replies

Write your reply to:

Draft