Small ASP cheat sheet: getting current path (absolute URL), getting current script name.
September 21st, 2007 by Denis GolovtsovAgain I’d like to present small collection of solutions for my not favorite technology (not confuse it with ASP.NET which I respect).
When need get the default URL for the current sub folder (that can be used for example to present a link on this section of site in mail), can be used following code:
‘
path = Left(Request.ServerVariables(“URL”),InstrRev(Request.ServerVariables(“URL”),“/”)
‘ if url need for a putting in email for example, so protocol and server name must e added
‘
url = “http://” & Request.ServerVariables(“SERVER_NAME”) & path
Also can be helpful getting the name of current script (for a generating conditional dependent content for example), following peace of code will helpful:
In this case we use the path variable that need get before, and if we’d like to get file without calculate it, we should use following code: