Public Function AppRoot() As String
        Dim appRelativeRoot As String = Me.ResolveUrl(”~”)
        Dim originalUrl As String = Me.Request.Url.ToString
        Dim pos As Integer = originalUrl.IndexOf(appRelativeRoot)
        Dim path As String = appRelativeRoot
        If pos > 0 Then
            path = originalUrl.Substring(0, pos + appRelativeRoot.Length)
        End If
        Return path
End Function

結果: =http://localhost:2622/

2.可以取得虛擬根目錄
Dim strUrl As String = Request.Url.GetLeftPart(UriPartial.Authority)

結果:strUrl =http://localhost:2622/demo/

arrow
arrow
    全站熱搜

    包爾伯 發表在 痞客邦 留言(0) 人氣()