Avoiding localhost

I’ve seen it over and over, programmers who use the literal “localhost” in their code. Together with Sitecore it’s absolutely NOT necesarry. Please, use Sitecore.Web.WebUtil.GetServerUrl() instead. It avoids plenty of strange issues while deploying.

Note: make sure that you place a slash after the output of the method as it doesn’t contain any by default.

By te way, it would be very cool to implement it by default in the UrlAgent in the scheduling section of the web.config. A lot of developers forget to configure it when they release their project… And the keepalive is very important as it makes sure all the Sitecore background threads stay awake :

<agent type=”Sitecore.Tasks.UrlAgent” method=”Run” interval=”01:00:00″>
    <param desc=”url”>http://localhost/sitecore/keepalive.aspx</param>

Properly a good suggestion to submit to Sitecore support… Tomorrow :P.

One thought on “Avoiding localhost”

Comments are closed.