When writing URI paths in ASP.Net, one of the most useful features the run-time provides you with is the web application root operator. The operator is nothing more than the tilde (~) character, yet it gives you the ability to start any path from the root of your website without having to resort to using multiple directory-up (..\) directives to set the path you need.
For example, take the scenario where your current page being processed is located at 'http://www.yoursite.com/Pages/Admin/Email.aspx', and you want to add an ImageButton that reference an image in the folder 'http://www.yoursite.com/Images/sendmail.jpg'. Without the web application root operator, you would have to write something similar to the following:
<asp:ImageButton ID="sendMail" runat="server" ImageUrl="../../Images/sendMail.jpg" />
While this works, it's far from ideal as the link to the image will break if the page hosting the ImageButton changes location, or if someone copy/paste's your ImageButton code into a different page with a different relative path.
However, using the web application root operator, you can simply write the control as follows:
<asp:ImageButton ID="sendMail" runat="server" ImageUrl="~/Images/sendMail.jpg" />
Now, it no longer matters where the page hosting this ImageButton control resides, the path will always be the root of the application + /Images/sendMail.jpg. The page may change paths, or someone may copy the code, but the path will always stay the same. This ends up being a much more robust solution, and looks much cleaner as well. There is one drawback, however, and that is the operator is only available to server-side controls, and cannot be used in client-side html elements.
Since the MVC framework does away with the use of most server controls, it first appears that using relative paths is the only way to go. Fortunately, there's a better option, the UrlHelper.Content() method!
In the current UrlHelper class, there's now a method called Content, which accepts a virtual path and turns it into an absolute path. The virtual path that is passed in can be pre-pended with the ~, and it works exactly as it does in ASP.Net:
<img src="../../Images/sendmail.jpg" />
Can be replaced with:
<img src="<%= Url.Content("~/Images/sendmail.jpg") %>" />
The syntax is a bit longer, however you still get the same benefits of starting your path off with the application root, instead of trying to navigate around using relative paths.