i want to get the fully qualified url to a resource in ASP.NET.
e.g.:
<LINK rel="shortcut icon" href="<%=GetFaviconPath()%>">
with the code-behind file right now containing:
private String GetFaviconPath()
{
String url = System.Web.VirtualPathUtility.ToAbsolute("~/Images/clock.ico");
return url;
}
Unfortunately this doesn't work because it doesn't return the fully qualified path, only the path relative to the server:
/Employement/Images/clock.ico
Internet Explorer requires a fully qualified url, e.g.:
http://localhost:62119/Employment/Images/clock.ico
http://avenger:81/Employment/Images/clock.ico
http://MyFreeAspDotNetHosting.com/IanBoyd/Employment/Images/clock.ico
How can i get the fully qualified path to a file? i've tried VirtualPathUtility
and i'm all out of ideas.
Try this
string _ApplicationPath = HttpContext.Current.Request.Url.ToString();
Append your relative path to that absolute path.