Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 8th, 2006, 07:02 AM
Authorized User
 
Join Date: Oct 2006
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default Retrieving url properties (2)

Is there a way in asp to retrieve part of the URL and use it

say the url was

http://localhost/site/craig/default.asp
or
http://localhost/site/craig/test.asp
or
http://localhost/site/craig/roger.asp?dan=1

is there anyway of retrieving the word craig so to use it in the page, I just want the word Craig

This is because i could have other addresses that are for example

http://localhost/site/jon/default.asp
or
http://localhost/site/jon/test.asp
or
http://localhost/site/jon/roger.asp

where i need to retrieve the word jon

at the moment i use the code

strURL = Replace(Request.ServerVariables("URL"), "/default.asp", "")

    intStart = instrRev(strURL, "/") + 1
    strName = mid(strURL, intStart)

this worked fine until new pages are added ie a page that isnt default.asp

Obviously i cant use strURL = Replace(Request.ServerVariables("URL"), "/default.asp", "") because default.asp will change...

please advise

thanks

 
Old November 15th, 2006, 05:50 AM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You could use:

aParts = Split(strURL, "/")

Now you will have the URL broken into an array, where:

aParts(0) = "http:"
aParts(1) = ""
aParts(2) = "localhost"
aParts(3) = "site"
aParts(4) = "craig"
aParts(5) = "default.asp"

Try:

For n = 0 to UBound(aParts)
  Response.Write "<p>Part Number " & n & " is <b>" & aParts(n) & "</b></p>"
Next

Regards,

Sean Anderson





Similar Threads
Thread Thread Starter Forum Replies Last Post
URL Redirect based on given URL somnath.kartic VS.NET 2002/2003 1 August 2nd, 2012 08:21 AM
URL rewriting with URL forwarding mtabyana BOOK: Professional Search Engine Optimization with PHP: A Dev's Guide to SEO ISBN: 978-0-470-10092-9 0 October 22nd, 2007 08:22 AM
extract URL from Favorites (.URL Files) PhilHawks VB.NET 2002/2003 Basics 2 November 2nd, 2004 04:35 AM
NEED HELP! retrieving from database nvillare .NET Web Services 5 October 22nd, 2004 12:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.