Feed on
Posts
Comments

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>
    <LogActivity>true</LogActivity>
</agent>

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

One Response to “Avoiding localhost”

  1. Hessner says:

    Hi, any comment from sitecore on this?

    We have not placed sitecore under localhost. In the log I see an 404 error every hour.

    What are the correct string to write here, is it:

    /sitecore/admin/keepalive.aspx ?

    If I use: http://www.mydomain.com/sitecore/admin/keepalive.aspx, direct in browser,- then I am prompted for credentials….?

Leave a Reply