Public Function FixUrl(ByVal Url As String) As String
Dim strReturn As String
If Url.StartsWith("~") And HttpContext.Current.Request.ApplicationPath <> "/" Then
strReturn = HttpContext.Current.Request.ApplicationPath & Url.Substring(1).Replace("//", "/")
ElseIf Url.StartsWith("~") Then
strReturn = Right(Url, Len(Url) - 1)
strReturn = Url
So what this function will do is take any URL that is passed (such as "~/admin/user.aspx") will return the proper directory.
If you are running your application at this URL: http://mytestapp.domain.com/, it will return "/admin/user.aspx". If you are running it locally for testing, such as http://localhost/mytestapp/, it will return "/mytestapp/admin/user.aspx".
10-07-2006 12:45 AM