In ASP.NET MVC how can I use the Razor @Url.Content() helper from C# code?
asp.net, asp.net-mvc
Solution
Use the following to mimic Url.Content in code.
VirtualPathUtility.ToAbsolute("~/url/");
Problem
I'm trying to write a html helper extension that outputs an image tag. I need to access (within C# code) something like Razor's @Url.Content() helper to get the proper URL for the current context. How does one do this?