Q:

How to get the sharepoint website url in a workflow from the current SPListItem?

I am using sharepoint 2010 and have created a workflow in vs. In this workflow I create some tasks and fill the title, bodytext and assign it to a user or group. In the bodytext I add an hyperlink as "a href". I try to get the link from the current item. The problem is that sometimes the link is not correct because the hostname is missing. This is the code:
SPListItem currentItem = workflowProperties.Item;
    string itemURL = currentItem.ParentList.DefaultDisplayFormUrl + "?ID=" + HttpUtility.UrlEncode(currentItem.ID.ToString());

    workflowProperties.Web.Site.WebApplication.Sites[0].Url + itemURL

Sometimes is works and than this is the hyperlink:
http://mywebsite.com/sites/RFC/Lists/Wijzigingsverzoeken/DispForm.aspx?ID=28

And sometimes it the link is not working, and is it like this:
sites/RFC/Lists/Wijzigingsverzoeken/DispForm.aspx?ID=28

It looks like the problem is inside this piece of code:
workflowProperties.Web.Site.WebApplication.Sites[0].Url

Does someone know where the problem is? Or what the best practice is to get the sharepoint website url?

A:

Why do you not use SPWorkflowActivationProperties.WebUrl ?
string url = workflowProperties.WebUrl;

or 
string url = workflowProperties.Web.ServerRelativeUrl;

