所以:我已经阅读了 8 个以上相对于绝对的堆栈溢出流。一些网站并转到了 MS 页面...
但是当我尝试过但没有成功时。然后我进行了更多研究,想知道我读到的解决方案不是 .asp 的一部分,而是 asp.net 的一部分? (是的,我是新手/新手/无知)
情况和我的愿望:
我有一个网站,最初只有一些产品和文本/图像页面(〜10),产品数量增加了一倍,我想要迁移到树结构以进行搜索引擎优化/个人理智/组织。
网站的原始构建者使用的这在单层设置上非常棒,就像现在一样。
即 example.com/page1.asp
现在,我将评论(冗长的多页产品报告)、添加多个产品等放在树的不同深度上。 上的相对包含,
example.com/products/super-widgets/widget/reviews/index.asp
<!-- #include file="../../../../../../inc-footer.asp" -->
因此,虽然我可以准确地连接到包含中断内的源
因为它们是相对的。正如我试图研究的那样,如上所述,我试图找到一种“最佳实践”,将 /inc-footer.asp 文件中的信息的相对值转换为绝对值。我考虑为代理设置绝对路径来获取全局图像
。
然而,我相信有人说这是一个糟糕的编码选择,我认为这是因为客户/网络访问者的体验速度,但我不知道这一点。
因此,我根据我之前的研究尝试了一些尝试和错误,但没有成功......
在我已经(但未能成功)的 include file.asp 中:
来自此站点的示例(链接 )我尝试过:
<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="" />
并且从MS(链接)我尝试过:
<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="" />
在写这篇文章时我参考了一些建议并尝试过失败(链接)
<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="" />
然后我认为我需要修改上面的示例并
<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="" />
再次尝试在编写此(链接)时使用交叉引用,我考虑了但包含文件没有
唯一成功我已经成功使用 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="" />
目前,该站点托管在 Windows Server 2003 Microsoft-IIS/6.0 上。
所有页面文件都是 .asp
我使用 Google chrome 来定义测试上述示例的成功。根据我的经验,如果它在 Chrome 中不起作用,那么就不值得在其他浏览器中进行测试。
谢谢。
凯西·伯内特
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
发布评论
评论(2)
Runat = Server 不适用于经典 ASP。经典 ASP 和 ASP.net 不可互换。他们的工作方式完全不同。
无论使用哪种框架,我发现当您的开发站点不使用本地主机时,根相对路径都可以很好地工作。
** 根相对示例**
这是一篇关于不同路径类型的文章:
http://brugbart.com/Articles/paths
如果可以的话我会使用根相对路径,如果不是的话使用绝对 URL。绝对 URL 的唯一缺点是 URL 中一些额外字符的下载开销。
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.