You can still use Url.RouteUrl , but in a slightly different way.
Put using System.Web.Mvc; at the beginning of your class (of course, you may need to add a link to System.Web.Mvc).
Then we get the Url object:
UrlHelper Url = new UrlHelper(HttpContext.Current.Request.RequestContext);
and access as usual: Url.RouteUrl .
source share