Okay... This is now VERY weird. Your post WAS there, but I didn't see it until this morning. [insert picture of monkey scratching his head here]
Now that I am able to get into my IDE, I can see that I have done something similar to Bill. Since my example would contain too much BL, I will expand on Bill's example some:
Public Function AddHost(ByVal URL As String) As String
' I added the use of String.Concat - this is MUCH faster on a high traffic site
' just in case a stateless thread calls this method (it could happen)
If HttpContext.Current Is Nothing Then
Return URL
End If
Dim result As String
'Dim host As String = HttpContext.Current.Request.ServerVariables("HTTP_HOST").TrimEnd("/"c)
' I usually use SERVER_NAME and haven't run into any problems yet
Dim host As String = HttpContext.Current.Request.ServerVariables("SERVER_NAME")
If URL.ToLower.Contains(host.ToLower) Then
result = URL
Else
If Not URL.StartsWith("/") Then URL = String.Concat("/", URL)
result = String.Concat(host, URL)
End If
Return DotNetNuke.Common.Globals.AddHTTP(result)
End Function
I haven't looked at it yet, but I assume that the DNN AddHTTP method determines whether the request is SSL or not. Like this:
Dim strHttp As String = String.Empty
If String.Equals(HttpContext.Current.Request.ServerVariables("HTTPS"), "ON") Then
strHttp = "https://"
Else
strHttp = "http://"
End If
Paul, your example looks fine, as long as it does what you need it to. I think these other two examples might be a bit more generic for your needs.