I'm extending Html.HtmlHelper
to render the breadcrumb depending on the page I am:
public static HtmlString RenderBreadCrumb(this HtmlHelper helper, PageType pagetype, object Model)
How do I use Url.RouteUrl
inside of an HtmlHelper to render the URL?
You need to create a new UrlHelper instance using a request context.
UrlHelper Url = new UrlHelper(helper.ViewContext.RequestContext);
Url.RouteUrl(…);
Just make a UrlHelper extension instead:
public static string RenderBreadCrumb(this UrlHelper helper, PageType pagetype, object Model)
Then call via:
@Url.RenderBreadCrumb(pageType, Model)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With