SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my workflow I've used the following for a http link to an item in sharepoint

workflowProperties.SiteUrl + ...

which returns http:\machinename\myweb

When people browse they use a domain name http:\sharepoint\myweb NOT the machine name. I believe there is an A record in IIS that does this routing. However if I was to browse http//machinename in the browser it remains as http//machinename. I want it automatically read http//sharepoint or in my workflow replace machinename to sharepoint.


share|improve this question
did my response help Raj? – Falak Mahmood Jul 8 '12 at 16:09

I assume you are referring to "host header" of the web application to which your site collections belong.

have you used workflowProperties.Site.HostName property to get the host name?

If you have alternate access mapping being set up, With that in mind, you can use the SPWebApplication's AlternateUrls collection to get the host header(s) associated with that web application.

Since it is possible to have multiple URLs associated with a single web application, you would need to iterate through this collection to get/find the host header you want. For e.g. function below return the URL in default zone.

private string LocalWebUrl()
    string localUrl = null;
    using (SPWeb web = workflowProperties.Site.RootWeb) {
        using (SPSite site = web.Site) {
            foreach (object altUrl_loopVariable in site.WebApplication.AlternateUrls()) {
                altUrl = altUrl_loopVariable;
                if (altUrl.UrlZone == Administration.SPUrlZone.Default) {
                    localUrl = altUrl.IncomingUrl.ToString;
    return localUrl;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.