~ explication

V

Vantroeyen

Hello,

What is the meaning of the ~ caracter in a Url

ex: "~/folder/..." ?

Regards
 
B

Bruno Jouhier [MVP]

~ is the home directory on Unix.

I don't really know what it can mean in a URL, though (which user?)

Bruno.
 
D

Dominique Kuster

Vantroeyen said:
Hello,

What is the meaning of the ~ caracter in a Url

ex: "~/folder/..." ?
In the context of an ASP.NET application ~ stands for the application
directory and most properties and methods using url will replace ~ with the
application root virtual path during rendering. This is very useful if you
want to reference a ressource without knowing the name of the application
directory.

Instead of writing urls like:
/myapp/images/ok.gif -> that could fail if myapp is once moved to
/allapps/myapp...
/images/ok.gif -> same problem
.../../images/ok.gif -> relative urls not always accepted and problems if the
owner page is moved

You would write :
~/images/ok.gif

I have tested this kind of urls for :
HttpResponse.Redirect
Hyperlink.ImageUrl, HyperLink.NavigateUrl
Image.ImageUrl

But I could not manage to find a proper documentation on this behaviour.

Hope it helps.
DK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top