asp.net core 6 strange attributes in tags when run
Asked Answered
B

1

6

I have a VS2022 asp.net core 6 web app that has invalid html tag attribute (b-g6ltozs93r) in many of the _Layout.cshtml tags when run. Here is an example from an untouched project. This doesn't occur with VS2019/.net5 or earlier. Happens with debug or release, local publish to folder or web deploy to server.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Home page - WebApplication1</title>
    <link rel="stylesheet" href="/lib/bootstrap/dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="/css/site.css?v=sjk3m9Ugj7rjYsMBDEOUmfKesxbo63CbCXLz0gPFM6c" />
</head>
<body>
    <header>
        <nav b-g6ltozs93r class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
            <div b-g6ltozs93r class="container">
                <a class="navbar-brand" href="/">WebApplication1</a>
                <button b-g6ltozs93r class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
                        aria-expanded="false" aria-label="Toggle navigation">
                    <span b-g6ltozs93r class="navbar-toggler-icon"></span>
                </button>
                <div b-g6ltozs93r class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
                   ...
                </div>
            </div>
        </nav>
    </header>
    <div b-g6ltozs93r class="container">
        <main b-g6ltozs93r role="main" class="pb-3">
            
<div class="text-center">
    <h1 class="display-4">Welcome</h1>
    <p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>

        </main>
    </div>

    <footer b-g6ltozs93r class="border-top footer text-muted">
        <div b-g6ltozs93r class="container">
            &copy; 2022 - WebApplication1 - <a href="/Privacy">Privacy</a>
        </div>
    </footer>

    <script src="/lib/jquery/dist/jquery.min.js"></script>
    <script src="/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="/js/site.js?v=4q1jwFhaPaZgr8WAUSrux6hAuh0XDg9kPS3xIVq36I0"></script>

<script src="/_framework/aspnetcore-browser-refresh.js"></script></body>
</html>```
Bettinabettine answered 11/5, 2022 at 23:36 Comment(0)
E
12

This is .net 6 new feature CSS Isolation.

If you don't want this, you can add <ScopedCssEnabled>false</ScopedCssEnabled> in your .csproj file, like below. And I have test it, it works for me.

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <ScopedCssEnabled>false</ScopedCssEnabled>
  </PropertyGroup>

</Project>
Eozoic answered 12/5, 2022 at 2:17 Comment(1)
Thanks. You saved me a bunch time. I came across the invalid attributes running validator.w3.org shown in Google Webmaster Guidelines developers.google.com/search/docs/advanced/guidelines/….Bettinabettine

© 2022 - 2024 — McMap. All rights reserved.