Reputation: 5247
I am having troubles hosting the blazor wasm asp.net core hosted
application.. The solution has 3 projects: Client, Shared, and Server.
when I run the command dotnet publish --configuration Release
it publishes the libraries to their respective folders in solution like this:
I would assume that since the server
project is referencing a client
- then my steps to host the application are following:
WebWorkbench3\Server\bin\Release\net5.0\publish
in powershelldotnet .\WebWorkbench3.Server.dll
https://localhost:5001/
_framework/blazor.webassembly.js
not being loaded.wwwroot
folder contents in the server app we will see the following:So this explains why the error is shown. However my question at this point - should the publishing process/configuration in project take care of copying client's wwwroot
contents into the the server's app output directory? If we start a debugging session in the VisualStudio, then we use the server
as the startup point, so the project should have some idea where to look up the blazor.webassembly.js
file at..
So why doesn't the same process occurs during the publishing?
Note: I was able to fix the issue by manually copying the client's wwwroot
directory and by placing the contents into the server's wwwroot
directory... But I don't think that is is how serving is supposed to work?
EDIT: I have just tried to set-up the client
blazor application in IIS. And it works. Kind of. The page is opened. But then when it tries to make a REST GET request to the server - it uses the same hostname:port
combination. So if my app is hosted on mysite.local:50001
then the request to API will look like mysite.local:50001/data/loadall
where data
is the controller name and loadall
is the action name.. So basically the client uses the same base address as the server.. The problem, is that I cannot start the server on the same port as the client! In attempt in doing so - you will see following output:
So basically I have the same question as before - how to host the wasm application that is split between client and the server? I am pretty sure that I can make it work by forcing the client to use the non-standard server port and serving the server
part on that port.. However, I believe there should be a reason why current configuration (default configuration in the blazor wasm template) is configured in this way so it should be possible to run the project somehow without any additional changes at all..
Upvotes: 5
Views: 3430
Reputation: 379
Having the samie issue as explained above:
Before:
The solution file
as the server project
Resolved
I moved the solution to the project root (one level up).
Now, dotnet publish
within the server project produced the __framework
folder + content as expected.
Upvotes: 1
Reputation: 5247
Well this will be a self-answer.. Instead of publishing (dotnet publish --configuration Release
) the application on solution level - do the publishing on project level..
..\repos\WebWorkbench3\WebWorkbench3
..\repos\WebWorkbench3\WebWorkbench3\Server
In 1 case the compiler does not copy the _framework
folder (and possibly some other files) into the wwwroot
.. Once you have published the Server correctly you can access the app by serving it with dotnet .\WebWorkbench3.Server.dll
command.
Upvotes: 3