获取应用程序的根Url
获取应用程序的根Url
VB代码
Public Function ApplicationRootUrl() As String
Dim req As HttpRequest = HttpContext.Current.Request
Return req.Url.GetLeftPart(System.UriPartial.Authority) + req.ApplicationPath & "/"
End Function
'调用方式如下:
ApplicationRootUrl() & "prg/if/ifShowMsgAddUp.aspx"
'结果:http://localhost:8010/iOffice/prg/if/ifShowMsgAddUp.aspx
Dim req As HttpRequest = HttpContext.Current.Request
Return req.Url.GetLeftPart(System.UriPartial.Authority) + req.ApplicationPath & "/"
End Function
'调用方式如下:
ApplicationRootUrl() & "prg/if/ifShowMsgAddUp.aspx"
'结果:http://localhost:8010/iOffice/prg/if/ifShowMsgAddUp.aspx