ResolveUrl/Url.Content Equivalent in Classic Asp

2019-01-28 00:41发布

In webform/mvc we can use script and links as, script src=" Url.Content("~/Scripts/util.js")"

Can anyone tell me what is the equivalent in classic asp?

1条回答
倾城 Initia
2楼-- · 2019-01-28 01:12

There is no direct equivalent, there isn't even a direct way to determine the applications virtual path. The following couple of VBScript functions should provide the feature:

Function UrlContent(sUrl)
    If InStr(1, sUrl, "~/") = 1 Then
        UrlContent = ApplicationPath & Mid(sUrl, 2)
    Else
        UrlContent = sUrl
    End If
End Function

Function ApplicationPath()

    Dim pos: pos = Len(Request.ServerVariables("INSTANCE_META_PATH")) + 6

    ApplicationPath = Mid(Request.ServerVariables("APPL_MD_PATH"), pos)

End Function
查看更多
登录 后发表回答