❔ Serving SPA on ASP.NET Core MVC Web API
Hi, I'm trying to serve SPA in a folder
client
in BaseDirectory. I want it to be served in "/".
Here's what I tried
And the fallback controller implementation is
But when i navigate to /
, I am getting
How do I do this correctly? Thanks in advance.8 Replies
error is pretty clear
there's no such folder or file as
ProjectDirectory\bin\Debug\net7.0\client
the folder you're telling it to serve your SPA files fromI can verify the folder exists
okay
well, the program disagrees
so I'm gonna have to say, "no, you didn't"
Do you have any tips to diagnose this situation?
By the way, I am trying another approach with the SpaExtensions, now the startup order looks like
It still complains the same thing, however the
client
folder exists on the project directory, and in bin\Debug\net7.0 directory
, I can explorer the\path\it\complains\not\found
and it is there
and I could go to localhost:port/index.html
and have index.html loaded in the browser
I appreciate your responseif you're going to instruct the app to serve up the SPA files from "ContentRoot/client" you need to put the files there
you seem to ve missing
.UseDefaultFiles()
A moment ago i got it working, not its not.
It now serves index.html, but when other files are requested, it says file not found while it is there
yeah, it's already there
okay i fixed it, apparently
To sum it up, i need to
then after the
UseStaticFiles
Thanks you for your responseshmmm, okay
I don't think I've ever used that extension, just the base StaticFiles middleware
can you not just swap that whole if chunk with
.StartsWith("/client")
?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.