Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Help: root path reference

Reply
Thread Tools

Help: root path reference

 
 
hb
Guest
Posts: n/a
 
      01-28-2005
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



 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      01-28-2005
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" <(E-Mail Removed)> wrote in message
news:ONgp5%(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
 
 
 
hb
Guest
Posts: n/a
 
      01-28-2005
Karl,

Thank you every much.
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:ONgp5%(E-Mail Removed)...
> > 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
> >
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reference to Virtual Root path not working John Kotuby ASP .Net 6 05-24-2007 12:08 AM
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
non root users accessing application installed with root instance hector C Programming 5 12-05-2006 01:01 PM
SRT DIvision, Square root and reciprocal square root alghazo@siu.edu VHDL 0 05-27-2004 06:23 AM
Tertiary Conditional: what does this evaluate to ("docRoot == null ? this.root : doc root")? Rick Osborn Java 10 02-08-2004 02:25 AM



Advertisments