将 html 帮助程序迁移到 ASP.NET Core [英] Migrate html helpers to ASP.NET Core

查看:14
本文介绍了将 html 帮助程序迁移到 ASP.NET Core的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一个项目转换为 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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