Reputation: 50190
I have a large working Blazor WASM app. When I started I thought I wanted a free standing one. Now I realize I should have select hosted - ie have it served by a separate asp.net web server. In order to see how that client seever combo should work I have created a test app in that configuration and cannot work out how it works.
The Web server BlazorApp1.Server is serving files from the wwwroot of the BlazorApp1.Client. But I dont see how it is getting to those files. I looked at the EnvironMent.WebRoot of the server and its not set, its ContentRoot points to itself
Apart from the webroot issue are there any other changes I would need to make. I looked at the project templates and could not see any obvious ones
Upvotes: 1
Views: 2313
Reputation: 273449
As far as I know there are no differences in the Client project between Hosted and Standalone.
In the Hosted setup, in your Server the key points are:
app.UseBlazorFrameworkFiles();
app.MapFallbackToFile("index.html");
I would create a new Hosted project and drop in the original Client project, fix the names (and namespaces) and link the Server to the right Client.
plus need to add nuget packages
I also added app.UseStaticFiles
Actually no, dont add devserver to the Server app. You want Server in the server app and devserver in the client
DevServer is a minimal kestrel server hard coded to nice defaults just for booting up a blazor wasm client. It also supports the debugging of the client c# code.
Upvotes: 1