gpt4 book ai didi

c# - 来自 Html 帮助程序扩展的 Url.RouteUrl

转载 作者:太空狗 更新时间:2023-10-29 21:06:43 26 4
gpt4 key购买 nike

我正在扩展 Html.HtmlHelper 以根据我所在的页面呈现面包屑:

public static HtmlString RenderBreadCrumb(this HtmlHelper helper, PageType pagetype, object Model)

如何在 HtmlHelper 中使用 Url.RouteUrl 来呈现 URL?

最佳答案

您需要使用请求上下文创建一个新的 UrlHelper 实例。

UrlHelper Url = new UrlHelper(helper.ViewContext.RequestContext);
Url.RouteUrl(…);

关于c# - 来自 Html 帮助程序扩展的 Url.RouteUrl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5597718/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com