Analytics


Google

Saturday, February 14, 2009

Getting your virtual path

Sometimes we need to obtain the virtual path to our page to pass into 3rd party applications. This can easily be done in asp.net by using

Request.ApplicationPath

However, if you are using asp classic, you will need some additional more coding. This is one way of doing it:

dim vUrl, arrStr, vStr
dim loopCnt
vUrl = Request.ServerVariables("PATH_INFO")
arrStr = Split(vUrl, "/")
vStr = "/"

for loopCnt = 0 to UBound(arrStr) - 1
if Len(vStr) > 1 then
vStr = vStr & "/"
End If
vStr = vStr & arrStr(loopCnt)
Next

No comments: