Absolute reference

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

How can I set an absolute reference to site root in a page link so the
referenced page is always accessed from the site root folder?

Thanks

Regards
 
John said:
Hi

How can I set an absolute reference to site root in a page link so the
referenced page is always accessed from the site root folder?

Thanks

Regards

You can use the "~" root operator:

<a href="~/Default.aspx" runat="server">Home</a>
 
Use ASP.NET server controls (e.g, Hyperlink). You can set the NavigatUrl to
something like "~/myfolder/myresource.aspx". The tilde (~) always will
resolve relative to to root of the web site.
Peter
 
Hi John,

In addition to Peter's and Goran's replies, every descandant that derives
from Control class has ResolveUrl() that converts a URL into one that is
usable on the requesting client.
 
Back
Top