admin管理员组

文章数量:1404467

I have started a .Net 9.0 'MAUI Blazor Hybrid and Web App' project. The solution contains the following projects:

  • myawesomeapp
  • myawesomeapp.Shared
  • myawesomeapp.Web
  • myawesomeapp.Web.Client

I am going to create mainly Blazor web assembly components in myawesomeapp.Shared, which can then be used in the mobile app and the web app. I would also like both applications to share a cascading style sheet, to avoid duplication and potential inconsistencies. I have tried calling the css from the App.razor file and the mobile index.html from a CDN site:

<link href=".css" rel="stylesheet"/>

But it doesn't it doesn't load. How might I reference the css file if I place it in the myawesomeapp.Shared project, please?

I have started a .Net 9.0 'MAUI Blazor Hybrid and Web App' project. The solution contains the following projects:

  • myawesomeapp
  • myawesomeapp.Shared
  • myawesomeapp.Web
  • myawesomeapp.Web.Client

I am going to create mainly Blazor web assembly components in myawesomeapp.Shared, which can then be used in the mobile app and the web app. I would also like both applications to share a cascading style sheet, to avoid duplication and potential inconsistencies. I have tried calling the css from the App.razor file and the mobile index.html from a CDN site:

<link href="http://cdn.myawesomedomain/cogs/myawesomestylesheet.css" rel="stylesheet"/>

But it doesn't it doesn't load. How might I reference the css file if I place it in the myawesomeapp.Shared project, please?

Share Improve this question asked Mar 11 at 10:00 sanepetesanepete 1,15211 silver badges33 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can put the css file below myawesomeapp.Shared\wwwroot\myawesomestylesheet.css.

And then you can load it in both App.razor file and the mobile index.html:

<link href="_content/myawesomeapp.Shared/myawesomestylesheet.css" rel="stylesheet"/>

本文标签: cHow might I share css files between both a MAUI Blazor mobile app and a Blazor web appStack Overflow