简体   繁体   English

C# Razor 添加奇怪的后缀到 Html 标签

[英]C# Razor Adding Weird Suffix to Html Tags

I'm using .NET 7, Visual Studio 2022 and Razor Pages, fresh razor page template project.我正在使用 .NET 7、Visual Studio 2022 和 Razor 页面,新鲜的 razor 页面模板项目。 Something is injecting a suffix b-1cs0j1knof after many of my html tags.在我的许多 html 标签之后,有些东西正在注入后缀b-1cs0j1knof This happens even in release/published build.即使在发布/发布的版本中也会发生这种情况。 How do I disable this?我该如何禁用它? Nothing comes up when searching online after a few hours so decided to post here.几个小时后在线搜索时没有任何结果,所以决定在这里发帖。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>SiteName</title>
</head>
<body>
    <header>
        <nav b-1cs0j1knof>
            <div b-1cs0j1knof>
            </div>
        </nav>
    </header>
    <div b-1cs0j1knof class="container">
        <main b-1cs0j1knof role="main">
            
<h2>Home Page</h2>
        </main>
    </div>
    <br b-1cs0j1knof/>
    <footer b-1cs0j1knof>
        <div b-1cs0j1knof>
            &copy; 2022 - 2022 SiteName
        </div>
    </footer>
</body>
</html>

TLDR; TLDR; If you don't want this feature, add <ScopedCssEnabled>false</ScopedCssEnabled> to your csproj file.如果您不想要此功能,请将<ScopedCssEnabled>false</ScopedCssEnabled>添加到您的 csproj 文件中。

From Reddit .来自Reddit

Those attributes are automatically generated by ASP.NET's css isolation feature, which is enabled by default.这些属性由 ASP.NET 的 css 隔离功能自动生成,该功能默认启用。 This lets you create a *.razor.css file and add styling specific to your razor file without affecting the rest of the page.这使您可以创建 *.razor.css 文件并添加特定于 razor 文件的样式,而不会影响页面的 rest。 ASP.NET will process the css and add attribute selectors matching what you're seeing on the rendered elements. ASP.NET 将处理 css 并添加与您在渲染元素上看到的相匹配的属性选择器。 See https://learn.microsoft.com/en-us/as.net/core/blazor/components/css-isolation?view=as.netcore-7.0请参阅https://learn.microsoft.com/en-us/as.net/core/blazor/components/css-isolation?view=as.netcore-7.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM