C
C#2y ago
mindhardt

✅ Access wwwroot in Blazor wasm razor

I have a blazor hosted project and a file in a wwwroot folder. This file needs to be accessed by razor component's C# code but I can't find any help googling. Right now this file is getting loaded from server but this is redundant since it is static.
5 Replies
mindhardt
mindhardtOP2y ago
I want this file to be included in client project and loaded from there, I know I can access them via HTML, but can razor do the same? I need file content
Monsieur Wholesome
You're using asp.net core to hort it?
Monsieur Wholesome
From what I can gather, you'd add the UseStaticFiles statement in your startup.cs/program.cs And make an http request to your wwwroot resource https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-7.0
Static files in ASP.NET Core
Learn how to serve and secure static files and configure static file hosting middleware behaviors in an ASP.NET Core web app.
Monsieur Wholesome
As in js you'd do the same
Accord
Accord2y ago
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. Closed!
Want results from more Discord servers?
Add your server