C
C#17mo ago
Lunar Source

❔ Blazor WebAssembly change index.html to .cshtml

Hello, I'm using .NET 7 Blazor WebAssembly Standalone (aka not ASP.Net Hosted). I am trying to figure out how to change the index.html to index.cshtml so I can use C# in the page. All articles and topics i've found are for Blazor Server and Blazor WASM hosted. In which they have access to
app.MapFallbackToFile("index.html");
app.MapFallbackToFile("index.html");
So I am trying to figure it out for not hosted Blazor WASM. The short description of why asking. Tired of dealing with Blazor caching .js and .css files causing problems with users after update having to clear cache/hard refresh etc. So I want to pull the assembly version in the page so i can do something like
@ {
string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
}

<script src="js/CustFunctions.js?v=@version"></script>
@ {
string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
}

<script src="js/CustFunctions.js?v=@version"></script>
So i can force the browser to recache stuff.
1 Reply
Accord
Accord17mo 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.
Want results from more Discord servers?
Add your server