Reputation: 22045
What is the benefit of using Url.RouteUrl or Url.Action versus just using the URL directly?
Upvotes: 2
Views: 1122
Reputation: 18065
It's very simple to set up custom routing rules to create so-called "pretty" (or SEO-friendly) URLs. If you ever change one of those URLs, you don't want to have to go through your entire application and change it every time you link to that action. On the other hand, if you use Url.Action
, it will change automatically.
Upvotes: 1
Reputation: 26678
If you change your routing configuration, by using Url.RouteUrl or Url.Action your generated Url's will update along with your routing configuration.
I find the real benefit comes when tied together with T4MVC. Then I have strongly typed access to my Action routes, so if my controller's change the compiler alerts me if any of my Url's need to change as well.
Upvotes: 1