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.Url + itemURL
Sometimes is works and than this is the hyperlink:
And sometimes it the link is not working, and is it like this:
It looks like the problem is inside this piece of code:
Does someone know where the problem is? Or what the best practice is to get the sharepoint website url?