[home]  [scripts]  [news]  [forums]  [feedback] 
Home
...a journey into a lost mind. Don't suppose you found it?
Get Application Root Path  (id:1503 ) (5753 hits)
Description:
This is a simple function I include in most of my apps, typically in a BasePage or BaseControl but you could easily put it in a Utility type class. What it does is return the current root for your site. This is kind of the equivalent of the "~/" in Asp.Net but it takes into account for ports, etc. Even if you use the File based websites (and get a site like http://localhost:12345/siteName it will return the root property ("http://localhost:12345")  
Code:
Public Shared ReadOnly Property UrlBase() As String
Get
Dim _return As String = ""
If HttpContext.Current.Request.Url.Port = 80 Then
_return = "http://" & HttpContext.Current.Request.Url.Host & HttpContext.Current.Request.ApplicationPath
Else
_return = "http://" & HttpContext.Current.Request.Url.Host & ":" & HttpContext.Current.Request.Url.Port & HttpContext.Current.Request.ApplicationPath
End If
If _return.EndsWith("/") Then
_return = _return.Substring(0, _return.Length - 1)
End If
Return _return
End Get
End Property
 
Created:
8/22/2007 7:31:00 AM 
Created By:
Curt 
Download URL:
 
Category:
ASP.NET/VB.Net 
Sample URL:
 
Updated:
2:00:00 AM 
RSS Subscriptions
Advanced Script Search

Keyword(s)


Category