✅ Works in live server, breaks in minimal server. I am a fool.
I'm doing something big-time stupid trying to serve this webpage
It works fine with the VSCode extension live server preview, but when I run my custom server, despite (as far as I can tell) serving all the files correctly with the correct mime types, I get a reference error immediately, with the inline JS unable to reference the
odin variable defined in odin.js
The line in question:
if i try to access odin.js in my browser directly, it's all there and looks like my server is serving it up fine.
The only main Thing i've noticed which might be causing problems, is that if I use HTTP (http://localhost:5134/) vs. HTTPS (https://localhost:7093/), it correctly redirects me to the HTTPS endpoint, but doesn't show the file until i manually refresh the page. So maybe that's related to what's happening here?5 Replies
It's a super basic asp.net minimal API thing:
There's not much surface area for me to be screwing this up, so I'm kind of impressed that I've managed it. Does anyone have a guess for where I'm going wrong? Thank you so much!
Hmmm youre trying to serve static files right? But looks like youre building this yourself in request pipeline.
Have you tried using the static file serving apis?
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-10.0
Static files in ASP.NET Core
Learn how to serve and secure static files and configure Map Static Assets endpoint conventions and Static File Middleware in ASP.NET Core web apps.


But if you still want to make current code works, apparently its missing some things
- Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) << use this to get the directory properly
- app.UseRouting() << to route your request properly
- youre not awaiting the SendFileAsync method too
- make sure you have this to your csproj too
<ItemGroup>
<Content Include="FrontendBuild**" CopyToOutputDirectory="Always" />
</ItemGroup>
Appreciate the heads-up! Making it async and awaiting was the trick!
awesome!!! :akshully: