Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Not generating CSS and copy JS and CSS from components

$
0
0

I have a simple .NET 8 Blazor application that I have to deploy on IIS version 10. I have installed .NET 8 on the server.

enter image description here

The Application Pool is configured as "No Managed code", but I also tried with the .NET CLR Version v4.0.30319.

enter image description here

I checked all the roles for the Web Server, and here is the screenshot of the services that are installed.

enter image description here

I created a new project out-of-the-box without anything else, using the "Interactive render mode" set to "Auto".

enter image description here

Because the application is running under a Web Application in IIS, I added in the appconfig.json the key BasePath to specified the path. For example, if the URL is https://myserver/test the BasePath is /test/. In the App.razor, I added this check

@inject IConfiguration Configuration@{    var basePath = Configuration["BasePath"] ?? "/";    basePath = basePath.EndsWith("/") ? basePath : basePath +"/";}<base href="@basePath" />

Locally, the project is working fine. I deploy via Azure DevOps pipeline, the application to the server, and the task is like that (buildConfiguration is Release)

    - task: DotNetCoreCLI@2      displayName: Build project      inputs:        command: 'build'        projects: '**/RiskExcessTool.csproj'        arguments: '--configuration $(buildConfiguration) -o $(Build.StagingDirectory)/ci-build'

Now, I open the application on the server, and I get this page without CSS

enter image description here

So, I opened the Dev Tools to inspect the issue. I can see that Blazor is doing its magic. All the tags have a Blazor identifier.

enter image description here

When I check the console, the CSS are not found. In particular, the RiskExcessTool.style.css is the CSS that Blazor should generate.

enter image description here

Here I can see that the blazor.web.js is loaded.

enter image description here

but the CSS isolation is not working.

enter image description here

When I add a component that has CSS and JS, those files are not found too. As a last resort, I deployed the application to one of my personal servers and the application is working fine. So, I think the issue is in the configuration on the IIS.

How can I resolve this issue?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>