473,385 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help: root path reference

hb
Hi,

Recently I read some articles about the root path reference in ASP.Net
application.
One recommended way is to use "~" at the beginning of the path with server
control.
for example:
<img runat="server" src="~/images/logo1.jpg">

Those articles also say that such method works with virtual directory as
well.

My question is: Is there any performance setback to use server side HTML
tag (like <img runat="server">)or even ASP.Net server control (like
<asp:image>)
instead of regular HTML tag (like <img>) just for root reference purpose?

Thank you

Hongbo

Nov 19 '05 #1
2 1362
Hongbo:
Yes, there is a performance setback, but it's very small and probably worth
paying it (we are talking microseconds most likely).

If this isn't acceptable, you can have a global class with a property such
as:

public sealed class Globals{
static public string ApplicationPath {
get {
string applicationPath = HttpContext.Current.Request.ApplicationPath;
if (applicationPath == "/") {
return string.Empty;
}
return applicationPath;
}
}
}
}

and then use src="<%=Globals.ApplicationPath%>images/logo1.jpg" but I my
personal opinion is that ~ is much nicer and cleaner with a very low cost.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"hb" <ho****@goodoffices.com> wrote in message
news:ON****************@TK2MSFTNGP12.phx.gbl...
Hi,

Recently I read some articles about the root path reference in ASP.Net
application.
One recommended way is to use "~" at the beginning of the path with server
control.
for example:
<img runat="server" src="~/images/logo1.jpg">

Those articles also say that such method works with virtual directory as
well.

My question is: Is there any performance setback to use server side HTML
tag (like <img runat="server">)or even ASP.Net server control (like
<asp:image>)
instead of regular HTML tag (like <img>) just for root reference purpose?

Thank you

Hongbo

Nov 19 '05 #2
hb
Karl,

Thank you every much.
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:Ok**************@TK2MSFTNGP11.phx.gbl...
Hongbo:
Yes, there is a performance setback, but it's very small and probably worth paying it (we are talking microseconds most likely).

If this isn't acceptable, you can have a global class with a property such
as:

public sealed class Globals{
static public string ApplicationPath {
get {
string applicationPath = HttpContext.Current.Request.ApplicationPath; if (applicationPath == "/") {
return string.Empty;
}
return applicationPath;
}
}
}
}

and then use src="<%=Globals.ApplicationPath%>images/logo1.jpg" but I my
personal opinion is that ~ is much nicer and cleaner with a very low cost.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"hb" <ho****@goodoffices.com> wrote in message
news:ON****************@TK2MSFTNGP12.phx.gbl...
Hi,

Recently I read some articles about the root path reference in ASP.Net
application.
One recommended way is to use "~" at the beginning of the path with server control.
for example:
<img runat="server" src="~/images/logo1.jpg">

Those articles also say that such method works with virtual directory as
well.

My question is: Is there any performance setback to use server side HTML
tag (like <img runat="server">)or even ASP.Net server control (like
<asp:image>)
instead of regular HTML tag (like <img>) just for root reference purpose?
Thank you

Hongbo


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Amadelle | last post by:
Hi all, I am so desparately in need of some guidance! After two days of struggling I still can't connect to the Active Directory server. I have used so many different ways and so many different...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
1
by: Amadelle | last post by:
Hi all, I am so desparately in need of some guidance! After two days of struggling I still can't connect to the Active Directory server. I have used so many different ways and so many different...
15
by: Lars Eighner | last post by:
Aside from the deaths of a few extra electrons to spell out the whole root relative path, is there any down side? It seems to me that theoretically it shouldn't make any difference, and it would...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.