SaaS CMS has officially launched! Learn more now.




My test site and localhost share the same database.

Under Admin / Manage Websites / Hostnames, I've added the following values:

  • *
  • localhots:12345

When running the website from localhost, UriSupport.SiteUrl returns instead of http://localhost:12345

I'm trying to convert an internal URL to an absolute external URL using this code snippet:

Global.UrlRewriteProvider.ConvertToExternal(urlBuilder, null, Encoding.UTF8);
var friendlyUrl = UriSupport.AbsoluteUrlBySettings(urlBuilder.ToString());

Any help would be greatly appreciated.

Feb 08, 2015 17:15


Hostnames are probably not checked in that method. What you need to change is the site URL (the box above the hostnames).

I've never used UriSupport.SiteURL, but I guess that a shorthand to SiteDefinition.Current.SiteURL,

Feb 08, 2015 18:45

Thanks for your help!

I cannot modify the site URL because EPiServer database is shared between localhost and, and is more important than localhost.

I could solve this in 2 ways:

  • Use the relative URLs instead of absolute URLs
  • Get Request.Url.GetLeftPart(UriPartial.Authority) and append urlBuilder.ToString()

I was hoping that this can be solved by some EPiServer function which takes hostnames and HttpContext.Current into account :)

Feb 08, 2015 20:24
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.