R – Getting (Public) Internet URL for the Sharepoint Portal Site

sharepointsharepoint-2007

I have a custom infopath workflow which allows users to submit expesne reports. Whenever someone submits an expense report in the Forms Library the workflow is initiated. The workflow checks the weburl and using a generic method creates a link to point to the workflow item and sends this link in a mail to the submitter and approvers.

Now what i want to achieve is that i need a way to point to the workflow item using a public url so even if the user is submitting a request from intranet or internet the link will be pointing to the internet url and hence the users can open items from their mailbox using internet url when the intranet is not available.

So i guess in short i need a way to get the public url for a site. Also keeping in mind that site may be extended for internet with some security settings in place. What would be the easiest and most efficient way to do this.

Best Answer

Relative path of you Page or the Link will be same irrespective of the Zone from which the user access the Site. All you need to change in the URL is the host name part.

You can get the URL for any Zone with the Following code

SPContext.Current.Site.WebApplication.GetResponseUri(Microsoft.SharePoint.Administration.SPUrlZone.Default).AbsoluteUri
Related Topic