As you probably know you can use the tilde sign (~) in ASP.NET to get the relative path of the root of your Web Site or Web Application. But unless using the Link Server Control or similar you may need some code to convert it to a correct url or get the absolute path.

Using a Server Control – example using the HyperLink Web Server Control

MyHyperLink.NavigateUrl = "~/Products/XYZ"

Using HttpRuntime.AppDomainAppVirtualPath

strAbsoluteUrl = HttpRuntime.AppDomainAppVirtualPath & "/Products/XYZ"

Using VirtualPathUtility.ToAbsolute

strAbsoluteUrl = VirtualPathUtility.ToAbsolute("~/Products/XYZ")

Thanks to Yousef