views:

119

answers:

2

It seems to me that it is more prevalent in asp.net to be "virtual directory agnostic" by always using virtual directory substitution "~/" form for paths, but this doesn't seem to be a big deal for other platforms where absolute paths are more common. I might name django as one.

Is it bad form to use absolute urls in asp.net? In other platforms? If so, why?

+2  A: 

I'm generally more inclined to use relative paths. It allows me to move my applications around if I have to, or to some extent I can rename directories without breaking things. I also find it easier to copy the application over from a test or development environment and not have to worry about absolute references breaking because of server name changes.

Jeremy
+1 relative paths make the app folder-portable; anything less is suboptimal
Steven A. Lowe
I agree, absolute paths will eventually become a hindrance.
Chuck Conway
+1  A: 

In most cases there isn't a reason to. Relative paths do the same job without tying down your website to a url. This is particularly handy when developing on a test server or software to run on multiple domains since it can be copied without harm.

If you do want to use absolute URLs, you should consider pulling the protocol and domain from the browser URL so at least it's still portable on your end.

Paulo