GetAbsoluteURL (.net)

I needed a way to easily convert a relative URL to an absolute URL for a link within a project I’m currently working on. I imagined I’d have to roll something myself and was starting to think it would have to be pretty complex… then .net suprised me 😉

Public Function GetAbsoluteUrl(ByVal currUrl As String, _
ByVal relUrl As String) As String
Dim baseUrl As New Uri(currUrl)
Dim destUrl As New Uri(baseUrl, relUrl)
Return destUrl.AbsoluteUri
End Function

Now that is nifty 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: