asp.net - Virtual Directory root vs Default web site root -
i using iis 5.1 in have only 1 default website,
i have 2 projects v2 , v3
my website points v2 projects , have folders images, styles etc have virtual directory under website hosting project v3 , having same folder hierarchy v2
in home page of both projects have
img src="\images\edlogo.gif" alt="logo"/>
but shows same image in v2 directory, how can show different images both projects. using "\" root of web site how can root of virtual directory under website
this static method returns full http path root folder of application (web site or virtual directory)
public static string getapprooturl(bool endslash) { string host = httpcontext.current.request.url.getleftpart(uripartial.authority); string approoturl = httpcontext.current.request.applicationpath; if (!approoturl.endswith("/")) //a virtual { approoturl += "/"; } if (!endslash) { approoturl = approoturl.substring(0, approoturl.length - 1); } return host + approoturl; }
so, can write in page:
<img src="<%= server.htmlencode(getapprooturl(false)) %>/images/edlogo.gif" alt="logo"/>
Comments
Post a Comment