C#
C#

help

Root Question Message

Hin
Hin12/1/2022
✅ 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.
Hin
Hin12/1/2022
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
OneWholesomeDev
OneWholesomeDev12/1/2022
You're using asp.net core to hort it?
OneWholesomeDev
OneWholesomeDev12/1/2022
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
OneWholesomeDev
OneWholesomeDev12/1/2022
As in js you'd do the same
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy