views:

380

answers:

1

Is there a built-in way of getting the full URL of an action?

I am looking for something like GetFullUrl("Action", "Controller") that would return something like http://www.fred.com/Controller/Action.

The reason I am looking for this is to avoid hardcoding URLs in automated emails that are generated so that the URLs can always be generated relative to the current location of the site.

+9  A: 

There is an overload of Url.Action that takes your desired protocol (e.g. http, https) as an argument - if you specify this, you get a fully qualified URL.

Paddy
Thanks Paddy, perfect!
Alan Spark
No bother - you'd think that there should still be a better way of doing this, but hey...
Paddy