Relative paths in MVC Razor

Did you know in Razor markup you can do this:


<img src="~/Images/downarrow.gif" />
<a href="~/somehwere">Link</a>

And it will get auto-resolved on render, such as:


<img src="/MyApp/Images/downarrow.gif" />
<a href="/MyApp/somehwere">Link</a>

Another welcomed gem in MVC 4 :)
comments powered by Disqus