等效于 ASP.NET 5 中的 MvcHtmlString? [英] Equivalent for MvcHtmlString in ASP.NET 5?

查看:16
本文介绍了等效于 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆