Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS are not applied to asp-page tag in razor pages

It's .NET6 razor pages project and I use VS2022.

This is in _Layout.cshtml.

<ul class="list-unstyled ml-2">
    <li>
        <a href="/TEST">TEST</a>
        <a asp-page="TEST/Index">TEST1</a>
    </li>
    ...

There are 2 anchor tag in nav bar but css in _Layout.cshtml.css is not applied to one with asp-page tag due to no attribute "b-l76pcumf24"

enter image description here

Could anyone explain why and how to make it work with asp-page tag helper?

Thanks

like image 994
dbenbyeon Avatar asked Oct 31 '25 23:10

dbenbyeon


1 Answers

CSS isolation is a build time feature. Tag helper output is generated at runtime, so they cannot support the CSS isolation feature. This is by design.

Set your own href attribute, like in your first link, and don't apply any custom asp-* attributes to the anchor.

like image 156
Mike Brind Avatar answered Nov 03 '25 13:11

Mike Brind



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!