so: I’ve read 8+ stackover flows on relative to absolute. A few sites and went to MS page on this…
however when I’ve tried and had not success. Then I researched more and wonder solutions I read about are not part of .asp and just asp.net? (yup, I’m a novice / newbie / ignorant)
The situation and my aspiration:
I have a site that was initial just a few products and pages of text / images(~10), the number of products has doubled and I want to migrate to a tree structure for SEO / personal sanity / organization.
The original builder of site used This was great on single layer set up, as it is now.
i.e. example.com/page1.asp
Now I’m putting reviews (lengthy multiple page product reports), adding multiple products, etc on different depths in a tree. So while I can accurately connect to a relative include on
example.com/products/super-widgets/widget/reviews/index.asp
<!-- #include file="../../../../../../inc-footer.asp" -->
the sources inside the include break on as they are relative.
As I have attempted to research, stated above, I have tried to find a “best practice” for converting the relative to absolute for the information in the /inc-footer.asp file. I have consider putting an absolute path for agent to get global images
<img src="http://example.com/images/ex1.png">.
However I believe some say this is a poor choice for coding, I think it is because of speed of experience of clients / web visitors, but I don’t know this.
So I have attempted a few trials and errors based on my earlier research with no avail….
inside the include file.asp I have (and failed to succeed with):
from this sites examples (link) I tried:
<img runat="server" src="~/images/tab-leftside.png" class="tab-img" width="22" height="20" /><a href="javascript:switchid('tab2');" onfocus="this.blur()" >Page 2</a><img src="" />
and from MS (link) I tried:
<asp:image runat="server" ImageUrl="~/images/tab-rightside.png" alt="design object" width="21" height="20" class="tab-img" /> <a href="javascript:switchid('tab1');" onfocus="this.blur()" >Page 1</a> <img src="" />
while writing this I referenced some of recommendations and tried & failed with ( link )
<img src="<%= VirtualPathUtility.ToAbsolute("~/images/tab-rightside.png") %>" class="tab-img" width="22" height="20" /><a href="javascript:switchid('tab2');" onfocus="this.blur()" >Page 2</a><img src="" />
Then I thought I need to modify above example and tried
<img src="<%= VirtualPathUtility.ToAbsolute("~/images/") %>tab-rightside.png" class="tab-img" width="22" height="20" /><a href="javascript:switchid('tab2');" onfocus="this.blur()" >Page 2</a><img src="" />
Again with cross reference in writing this (link), I considered a but the include file has no
Only success I have had success with absolute path to http://
<img src="http://example.com/images/tab-leftside.png" class="tab-img" width="22" height="20" /><a href="javascript:switchid('tab2');" onfocus="this.blur()" >Page 2</a><img src="" />
Presently, the site is hosted on Windows Server 2003 Microsoft-IIS/6.0
All of the page files are .asp
I use Google chrome to define success in testing above examples. As I experience if it doesn’t’ work in chrome it’s not worth testing in other browsers.
Thanks.
Casey Burnett
Runat = Server won’t work for classic ASP. Classic ASP and ASP.net are not interchangeable. They work completely differently.
Regardless of framework I’ve found Root relative paths work well when your development site is not using local host.
** Root Relative example**
Here is an article on the different path types:
http://brugbart.com/Articles/paths
If you can I would use Root Relative paths, if not use absolute URLs. The only penalty for Absolute URLs the download overhead of a few extra characters in the URL.