Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

Thanks

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

1 Answer 1

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
add comment

Your Answer

 
discard

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.