Saturday, April 01, 2006

~ = friend

One of those nice little things not many people know about is the use of a ~ character in relative URLS. The ~ allows you to access the document root.

i.e. Show the log

If this was in a virtual directory called sampleapp the url would render to be

http://localhost/sampleapp/showlog.aspx

but when deployed to a production and not in a sample app it would be
http://www.sampleapp.com/showlog.aspx


if we just had a link without the tilde like this:
i.e. Show the log

then it would work in production but in development it would render to the root of the server
i.e. http://localhost/showlog.aspx
instead of the vdir like we want :)

Just a little trick. I am not sure if this works on apache or not or if IIS is finding those ~'s and replacing them for the user.

0 Comments:

Post a Comment

<< Home