等效于 ASP.NET 5 中的 MvcHtmlString?

编程入门 行业动态 更新时间:2024-10-24 10:25:13
本文介绍了等效于 ASP.NET 5 中的 MvcHtmlString?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在 ASP.NET 5 中是否有 MvcHtmlString 的等价物?否则,我们如何才能正确地从我的自定义 HTMLHelper 方法呈现 HTML 输出?

Is there an equivalent for MvcHtmlString in ASP.NET 5 ? Otherwise, how can we render HTML output from my custom HTMLHelper method properly ?

推荐答案

不再需要 MvcHtmlString(出于兼容性原因添加在 HtmlString 之上)所以您可以简单地使用 Microsoft.AspNet.Mvc.Rendering.HtmlString.

There is no longer need for MvcHtmlString (which added on top of HtmlString for compatibility reasons) so you can simply use Microsoft.AspNet.Mvc.Rendering.HtmlString.

您很容易注意到,Asp.Net 5 的 ViewComponents 和 Helpers 也使用(通过返回)相同的 HtmlString 到视图.

As you can easily notice, the ViewComponents and Helpers of Asp.Net 5 are also using (by returning) the same HtmlString to the views.

更新(适用于 ASP.NET Core 3.1):

您需要使用 Microsoft.AspNetCore.Html.HtmlString 代替.

You need to use Microsoft.AspNetCore.Html.HtmlString instead.

更多推荐

等效于 ASP.NET 5 中的 MvcHtmlString?

本文发布于:2023-11-17 04:37:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608850.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ASP   NET   MvcHtmlString

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!