Do you avoid hardcoding URLs (“../”, “~/”, or “/”) and use Url.Action or Html.ActionLink instead?
8/03/2013 5:53 AM by
Hardcoding URLs in your View can cause problems if your routes or page names need to change. Instead, you should always use the Url and Html helpers to refer to different pages in your MVC application.
<a href="/Rule/Create">Create a Rule</a>
- Figure: Bad Example – Hard-coded URLs may lead to broken links if routes change
@Html.ActionLink("Create a Rule", "Create", "Rule")
- Figure: Good Example – Use the Url or Html helpers to provide links
Do you feel this rule needs an update?