Error In Deploying Core Hosted Blazor WASM

Balu Raju 76 Reputation points
2022-06-24T18:33:40.54+00:00

This will be a very basic question, so I'm sorry to write it up.
I tried to deploy a very basic Blazor WASM app created out of VS template with WeatherForecast. No changes were made. Ran locally good.
Tried to publish and deploy on the server. I referred https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-6.0&tabs=visual-studio

As usual solution has three projects <name>.client, <name>.server and <name>.shared.
I chose to publish to the local folder. I did from VS choosing server project (not the client project).
I then copied the content to IIS physical path folder. The web server already has 6.0.4 hosting bundle installed.

I tried to access the app in browser got eh following errors because it could not load Client's CSS files.
Failed to Load Resource : <name>.CLient.styles.css
Failed TO load Resource: bootstrap.min.css
Failed to load resource: blazor.webassembly.js.
Failed to Load Resource: app.css

What am I missing? Should I also publish and deploy the client project? wwwroot folder has all these files generated from publishing the server project.

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,395 questions
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 56,686 Reputation points
    2022-06-24T20:02:03.12+00:00

    the blazor client project is setup to run as a root site. (https://servername)

    you are probably hosting as a subset (https://servername/mysite). in index.html you need to update:

    <base href="/" />

    to be your subsite:

    <base href="/mysite/" />

    note: unlike react spa, the index.html file is not generated at publish, so its hand edited. you can use a sed script to edit, or as MS suggests, run locally as a subsite with the same name:

    https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-6.0

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Balu Raju 76 Reputation points
    2022-06-24T20:24:24.503+00:00

    I'm replying to Bruce-SQLWork.

    It worked . but it looks like it is Case Sensitive , is it supposed to be?. I modified the Base URI to say /MySite/, which is what virtual directory is, but when I put my url in the browser as "mysite", it did not work and got an error.
    Thanks, but when I did got a different error
    "<mysite>/mysite is not contained in the base URI - "<mysite>/MySite"

    0 comments No comments