[英]Razor asp- tag helper is not recognized
I have following HTML code我有以下 HTML 代码
<a asp-action="index">Demo</a>
the asp
tag is not recognized by Visual Studio 2022 Visual Studio 2022 无法识别
asp
标记
and when I build and run the solution the asp
tag is not translated into the html code当我构建并运行解决方案时,
asp
标记未转换为 html 代码
There are no warnings, errors or JavaScript errors.没有警告、错误或 JavaScript 错误。
I copied the Views
folder from .NET Core 2.1 MVC
into the .NET 6 Core MVC
project.我将
Views
文件夹从.NET Core 2.1 MVC
复制到.NET 6 Core MVC
项目中。 The Index.cshtml
file has BuildAction = Content
property as other files in the View
folder. Index.cshtml
文件与View
文件夹中的其他文件一样具有BuildAction = Content
属性。
What might went wrong, why the tag helper is not translated?可能出了什么问题,为什么标签助手没有被翻译?
I finally figured it out.我终于弄明白了。 The reason was that I had file
ViewImports.cshtml
but it should be named _ViewImports.cshtml
.原因是我有文件
ViewImports.cshtml
但它应该命名为_ViewImports.cshtml
。 I don't know how that happened, but in this discussion https://social.msdn.microsoft.com/Forums/en-US/f9d42158-3bb6-490c-a59f-579eedeb060f/razor-not-rendering-tag-helper?forum=aspdo.netcore the another user had the same issue我不知道这是怎么发生的,但在这个讨论中https://social.msdn.microsoft.com/Forums/en-US/f9d42158-3bb6-490c-a59f-579eedeb060f/razor-not-rendering-tag-helper ?forum=aspdo.netcore另一个用户有同样的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.