Lớp helper:
public static class UrlHelper
{
private static System.Web.Mvc.UrlHelper _urlHelper;
public static System.Web.Mvc.UrlHelper GetFromContext()
{
if (_urlHelper == null)
{
if (HttpContext.Current == null)
{
throw new HttpException("Current httpcontext is null!");
}
if (!(HttpContext.Current.CurrentHandler is System.Web.Mvc.MvcHandler))
{
throw new HttpException("Type casting is failed!");
}
_urlHelper = new System.Web.Mvc.UrlHelper(((System.Web.Mvc.MvcHandler)HttpContext.Current.CurrentHandler).RequestContext);
}
return _urlHelper;
}
}
Việc kêu gọi:
UrlHelper.GetFromContext().Action("action", "controller");
Đây phải là câu trả lời. – ivowiblo