问题描述
我正在将一个项目转换为 ASP.NET Core.我需要迁移大量可重用的 html 助手,但 Core 中不存在 html 助手.
I'm converting a project to ASP.NET Core. I need to migrate lots of reusable html helpers, but html helpers do not exist in Core.
有些复杂,有些简单.这是一个非常简单的例子:
Some are complex, some simple. Here's a extremely simple example:
@helper EditIcon()
{
<i class="glyphicon glyphicon-pencil"></i>
}
请注意,这只是一个示例.
Note that this is only an example.
Point 正在为此编写一个标签助手,这是巨大的矫枉过正. 对于部分内容也是如此.视图组件也是如此.
Point is writing a tag helper for that is gigantic overkill. Same for partials. Same for view components.
我们谈论的是 Razor 的一小部分.我最好的选择是什么?
We're talking about a little snippet of Razor. What is my best option?
推荐答案
看来只有三个选项:
So, seems there are only three options:
- 标签助手李>
- 部分
- 查看组件
所以没有简单的方法来迁移 Razor 代码片段,而不需要跳过障碍.
So no simple way to migrate Razor snippets, without jumping through hoops.
编辑
所以 看起来像 html helpers 毕竟可用.他们只是没有被正确记录!
So looks like html helpers are available after all. They just haven't been properly documented!
这篇关于将 html 帮助程序迁移到 ASP.NET Core的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)