Click here to Skip to main content
13,260,113 members (49,838 online)
Click here to Skip to main content
Add your own
alternative version


6 bookmarked
Posted 12 Feb 2011

Get File name from URL Path - ASP Classic

, 12 Feb 2011
Rate this:
Please Sign up or sign in to vote.
Get File name from URL Path - ASP Classic

The following VBScript function can be used in an ASP legacy application to extract the file name from a request.

public function GetFileName()
    dim files, url, segments

    'get then current url from the server variables
    url = Request.ServerVariables("path_info")

    segments = split(url,"/")

    'read the last segment
    url = segments(ubound(segments))
    GetFileName = url
end function 

The function returns the last segment of the path information or URL. These are some examples:

URLFile Name
http://mydomain/products/The default page in that directory(check web server settings)

This is useful when there is the need of an application rule associated to the file name. For example, a new rule may need to be created on your legacy application because robots are exploiting a security hole in your application. You may want to protect some pages that can be used to update information , and you want to add a security policy to only those pages. This function can be used to know the target page on the request and apply the security rule if the page has been configured to be protected.

I hope this is useful to someone.



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

ozkar garcia
Architect OG-BITechnologies
United States United States

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171114.1 | Last Updated 12 Feb 2011
Article Copyright 2011 by ozkar garcia
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid