.NET 8 Blazor server web app : use different style libraries - Stack Overflow

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

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742348675a4427065.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信