admin管理员组

文章数量:1336139

I hope to have two different pages in the web app that use different style libraries, such as one using Bootstrap 3 and the other using Bootstrap 5

In .NET 7, two different implementations of _host.cshtml can be used. However, in the .NET 8 web app, there is no longer a host.cshtml file and it has been replaced by an app.razor file.

May I ask how to fulfill my above requirements?

I hope to have two different pages in the web app that use different style libraries, such as one using Bootstrap 3 and the other using Bootstrap 5

In .NET 7, two different implementations of _host.cshtml can be used. However, in the .NET 8 web app, there is no longer a host.cshtml file and it has been replaced by an app.razor file.

May I ask how to fulfill my above requirements?

Share Improve this question edited Nov 20, 2024 at 17:12 marc_s 756k184 gold badges1.4k silver badges1.5k bronze badges asked Nov 20, 2024 at 15:34 King LeeKing Lee 331 silver badge2 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You may try

@if (somecondition)
    {
        <link rel="stylesheet" href="......."]
        
    }
    else
    {
        <link rel="stylesheet" href="......."]
    }

.....

@code{
    // condition based on httpcontext
    [CascadingParameter]
    HttpContext? context{ get; set; }

}

in app.razor

when you navigate to pages in diffent styles,you need a full-page reload

本文标签: NET 8 Blazor server web appuse different style librariesStack Overflow