If you do this conversion in the controller, I would prefer VirtualParthUtility.ToAbsolute () over Url.Content ().
Profit appears when you want a unit test controller action. Instead of calling it directly, I would define the IPathUtilities interface, say, with one implementation, using the VirtualPathUtility methods for the site in real time, and the other used some kind of layout when testing.
If you call VirtualPathUtility directly, you wonโt be able to check the action method (you might have thought that some kind of smart mockery of the HttpContext would work around this, but after trying this, I couldnโt find a way to do it).
Appetere
source share