❔ Deploying a Blazor WebAssambly app.... but how??
I'm about to finish a front end that I have written in Blazor Wasm. Now I want to deploy it, so that I have a neat little folder with index.html in it as well as css, js, and pages folder. Just like if I'd built in in HTML and JS from scratch. Like your standard folder and file structure to host it on any simple webserver. Now I have tried using the Publish tab and published it to a folder. I've also tried using the console. But I only get some css and an index.html in that resulting folder that does nothing.
None of my created pages are there.
What am I doing wrong? I have not changed any project structure since creating the project from a wasm template
63 Replies
Do I need to move stuff into the wwwroot folder in my project structure? And if yes, how? Just drag and drop everything in? Does the Program.cs also go there?
@Turwaith You don't need to move anything anywhere.
Since you're using WASM, I assume non-hosted? So you only have one project?
If so, just build/publish it then execute the program.
The program will start all the dependencies and host on whatever bind address you picked.
Simply navigate to that address and there's your website.
Well technically it's a school project, and it's more about the back end (which is written in java, so totally different location). The front end (my blazor wasm) is not really gonna get rates, but it should work.
So my teacher just needs to be able to start the website and use it.
I was under the assumption that when building a blazor wasm project, I will in the end get a folder with the classic website structure, where you can just open index.html and everything works
Nothing changes, build/publish your project and execute the program
It's my first time using Blazor and a friend told me wasm was better for that use case than server
Execute the program.... so there should be an exe lying around somewhere?
Blazor Server needs both the frontend and the server part, yes. WASM is just the frontend
After you publish it in
if you just build it, it'll be in the Debug or Release folder
Debug/publish/projectname.exe
or Release/publish/projectname.exe
(assuming Windows)if you just build it, it'll be in the Debug or Release folder
.../bin/netX.0/...
When I was deploying my Wasm app, the files I had to deploy were all under
Long2Short/bin/Release/net5.0/publish/wwwroot/
Lemme dig that whole project up and seeYou'd have had to publish the entire
publish
dir as dependencies though right?
wwwroot
is just SPA frameworkThere is a shit ton of dlls in that folder but no exe
Well... yeah
Published or Built? 😄
You can't run an exe in the browser
published
Blazor WASM works by running the .NET runtime in the browser with WASM
It loads up the
.dll
s
.exe
is a Windows thingYeah, ZZZ correct if wrong, but I'm pretty sure you need to run the server-side since SPA can't be accessed from a static htm or whatever.
Of course it can
Yeah I know but I was just told by Ayymoss to look for an exe
Blazor WASM is just a regular ol' SPA page
Like with Vue or React or what have you
There's zero need for any sort of a server
What file would Tur need to run to access just the front end?
All of those files
Then they'd need to run some sort of a local server to serve those static files
Could be as simple as
php -S localhost:5000
or whatever;l
Or just run the associated Blazor server with the WASM build 😄
Since the
file://
protocol doesn't really let you load up external resources well
I meanSeems over complicated to run a separate server
If you have both the backend and the frontend, then sure
@Turwaith How did you create the project?
They can run the whole ASP.NET WebaAPI project, and that will serve the WASM frontend
But from what I hear, this is just the WASM frontend
Yeah, I used Hosted WASM for my Blazor app and I run server-side stuff.
No server to speak of
ZZZZ are you familiar with OGP?
No clue what that is
Just the usual New project --> Blazor WebAssembly App
Open Graph Protocol 😦
Ah, the
og:thumbnail
metatag stuffs?yaya
Can you help me in #✅ Blazor WASM - Dynamic Open Graph Protocol ?
@Turwaith Blazor WASM is server-side included
this is how I'm publishing it
Okay - ZZZ's correct. I've never built a WASM non-hosted app before 😄
There's no server in question here, just the wasm app
Alright, look. I have a Java Spring Backend. That is the part of the school project that is being graded. The spring API is running on localhost on port 8080. I just need my front end to open the webpage I created in my wasm project and send the requests I programmed to this IP/port. Whatever it takes to achieve this ^^
You need to run a server, see ZZZ's php suggestion
Out of curiosity, doesn't spring have front-end capabilities?
The gist is, you need to serve it somehow
I don't know ^^
With php server, spring, whatever
Okay so..... If I created this front end in raw html and javascript, I could just double click my index.html file, it opens in the browser and everything works.
Now of course the browser understands javascript but obviously not C#. Is there no way of starting and using my front end just as easy as it were if I built it from scratch in html and javascript?
Does it work if you do it like that?
If I click the index.html that gets created here?
y
No it does not work. I know that ^^
I was wondering if there is a way to achieve exactly this somehow
But it seems no
theres your answer
you can make spring serve it tho
probably
just like it would serve a react spa or we
Alright thanks. Now I need to find out how to do this
^^
Would it be worth moving your stuff to a Blazor Hosted application?
probably not
Nah I spent like 1h on that front end, most of its logic written by ChatGPT even.
I didn't want to bother with javascript just for a school project where the front end doesn't even really matter that much, so I thought I'm gonna to it in Blazor since I already know C#
Thought that would be simpler
Based. 😄
Turns out: Not necessarily, looking at my problems right now
I'm working on my biggest project and it's all in Blazor Hosted. Front and Back, so far very happy with no Javascript.
It's a blessing
Yeah, if there were really a using of my project I would love to just deploy it onto some service that can handle wasm projects.
But since I want something that I can just send to the teacher and he can just open and use it..... seems to me that blazor was like the worst possible choice for that ^^
Maybe I need to tell him to just download visual studio real quick and open it inside there. That's probably the easiest way
uh
Downloading the .NET SDK and
dotnet run
on your project will be much fasterhang on
Wow that's genius
I will just tell him that :D
Thanks for the help :D
It was literally all I needed for this purpose ^^
Just make sure it's the appropriate version
Won't be able to run a .NET 7 project using .NET 6 SDK
Yeah I tell him to download version 7
All that should work on linux too right, including the command
dotnet run
?
And if it doesn't I don't care anymore, he will be able to somehow get his hands on a windows machineYeah, should work on Linux just fine
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.