Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 31st, 2007, 07:26 AM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hard coded paths

Hi,

I just wanted to find out what the general consensus was on hard coded paths to scripts within a website.

Do you fully qualify the path or not?

For example in a web app I worked on previously we set an application variable in global.asa with the root URL e.g. Application("URL") = "http://www.somewebapp.com/"

Then whenever we referenced another page in the code we used this application variable e.g. Response.Redirect Application("URL") & "default.asp" or <IMG src="<%= Application("URL")%>images/Logo.gif" />

I'm currently working on a web app that we are migrating to a new server and none of the paths are fully qualified. e.g Response.Redirect "default.asp" or <IMG src="images/Logo.gif" />.

I don't imagine there will be any problems with pages not found after the migration but just wondered whether it was worth implementing fully qualified URL's whilst I have the opportunity.

Thanks for your ideas.

Best Wishes,

Paulie


__________________
http://www.thewebsiteshop.co.uk
Reply With Quote
  #2 (permalink)  
Old January 31st, 2007, 09:53 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

In so far as paths are required, its personal prefereance really. I prefer to use Relative paths to absolute but it is entirely up to you as the coder.



================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Reply With Quote
  #3 (permalink)  
Old January 31st, 2007, 08:25 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Personal preference it sure is. I was steered towards absolute paths and use almost the same process as pauliehaha has explained. I place constants in a global file however its not the global.asa

Any care to have a chat about the pros and cons of absolute Vs relative paths? Both work we all know however Ive always wondered why people wouldnt use absolute, providing they are globally changable.

Wind is your friend
Matt
Reply With Quote
  #4 (permalink)  
Old February 1st, 2007, 09:57 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

From an SEO prespective, you will want to use Absolute as crawlers can miss some relative links (parapharsed from google on their webmaster help, albeit that page has now changed and I can't find the exact text anymore) but in that instance, it applies only to your important pages, eg: www.yoursite.com/forums I dont think anyone will care if www.yoursite.com/privacy.html doesn't get indexed.

Again, it comes down to personal prefereance (doing a rudimentary search on this subject, returns threads just like this one) and there is no real "right" way to do this it seems and I didn't see anything on the MSDN supporting one method either way.



================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Reply With Quote
  #5 (permalink)  
Old February 2nd, 2007, 07:26 AM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Very useful, thanks.

I guess because I've always used absolute that's where my preference lies. Having to read and maintain code I've always found something like:

<img src="<%= Application("URL") %>images/home.gif">

much more readable than:

<img src="../../../images/home.gif">

for example. Also when writing such relative paths I always find myself mentally traversing the directory tree trying to work out how many dots and slashes I need to add!



http://www.thewebsiteshop.co.uk
Reply With Quote
  #6 (permalink)  
Old February 2nd, 2007, 07:32 AM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've just thought of a good reason to use absolute paths - in include files. Since an include could be included in any page at any level of the directory structure of a web site using relative paths might cause problems.

So since one would have to use absolute paths under these circumstances I would add that in order to remain consistent throughout the site absolute paths are the way to go.



http://www.thewebsiteshop.co.uk
Reply With Quote
  #7 (permalink)  
Old February 2nd, 2007, 09:40 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

While i agree with you in consistency, I do not agree with your last statement.  Since I am more used to using relative paths I have always used relative paths when linking my inculdes and have never had a problem with any of my pages loading the includes.  

In so far as mentally traversing the directory tree, again it is what you are used to.  By just looking at this:
<img src="../../../images/home.gif">

I know that the page that is calling the image file is 3 directories deep from the root without causing myself any mental angst.  In any case I can liken this discussion to that of the Mac vs Windows vs Linux debate.  Which camp is right in that arguement?

The answer is: They all are.  The reason is because its a subjective debate, much like this one, because the ppl that use those platforms and, are subsequentially proponents of that platform,  since the platform does what they need it to do it is the "best".

In our case here, there is no silver bullet into which way is the best.  As a programmer it is up to you to decide which type of path to use, which one you are comfortable, etc.

================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Reply With Quote
  #8 (permalink)  
Old February 6th, 2007, 05:16 AM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Agreed - it's all about preference at the end of the day. I'm not proposing absolute is better - it just seems the way to go for me :)

However from this I have identified a couple of instances where each method has a benefit so it's the way to go for me in most, but not all, cases.

For example, I can't do this:



and this defeats the object of storing the website path in an application variable in the first place:



So relative paths seem more appropriate for include statements.

But if I stick <img src="../../../images/home.gif"> in an include file and then include that file in a page that is only 2 directories deep from the root then the image would not get displayed. So in include files absolute path's seem more appropriate.

This discussion has been really useful, once again thanks for your input.


http://www.thewebsiteshop.co.uk
Reply With Quote
  #9 (permalink)  
Old February 6th, 2007, 06:48 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;But if I stick <img src="../../../images/home.gif"> in an include file and then include that file in a page that is only 2 directories deep from the root then the image would not get displayed. So in include files absolute path's seem more appropriate.

Very true. Another good reason to use absolute

IMO dparsons 'SEO prespective' comments above are reason enough. I am yet to hear a disadvantage of using absolute, there are clear advantages therefore can not imagine why one would use relative. NOTE I do not imply this for include file references, as pauliehaha pointed out, you can not unless its hard coded.


Wind is your friend
Matt
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is coded needed on every page? rtr1900 SQL Language 1 March 1st, 2006 06:53 PM
Hard coded examples etrump BOOK: Professional Ajax ISBN: 978-0-471-77778-6 1 March 1st, 2006 02:10 PM
The solution hard coded "ThePhile" jackchua BOOK: ASP.NET Website Programming Problem-Design-Solution 3 October 21st, 2004 12:25 AM
text comparison - changes color coded jringwald Javascript How-To 0 June 30th, 2003 09:37 AM



All times are GMT -4. The time now is 01:35 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.