diff --git a/src/Assets/build/Microsoft.AspNetCore.App.Internal.Assets.targets b/src/Assets/build/Microsoft.AspNetCore.App.Internal.Assets.targets
index b0199f2eeed7..d2517e511d2e 100644
--- a/src/Assets/build/Microsoft.AspNetCore.App.Internal.Assets.targets
+++ b/src/Assets/build/Microsoft.AspNetCore.App.Internal.Assets.targets
@@ -40,7 +40,10 @@
<_FrameworkStaticWebAssetCandidate Remove="@(_MissingFrameworkStaticWebAssetCandidate)" />
-
+
<_FrameworkAssetsPath>$(IntermediateOutputPath)frameworkassets
diff --git a/src/Components/WebAssembly/DevServer/src/Server/Startup.cs b/src/Components/WebAssembly/DevServer/src/Server/Startup.cs
index d23291a6dbd9..4be74f8b19d6 100644
--- a/src/Components/WebAssembly/DevServer/src/Server/Startup.cs
+++ b/src/Components/WebAssembly/DevServer/src/Server/Startup.cs
@@ -6,6 +6,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server;
@@ -69,6 +70,14 @@ public static void Configure(IApplicationBuilder app, IConfiguration configurati
{
OnPrepareResponse = fileContext =>
{
+ // Avoid caching index.html during development.
+ // When hot reload is enabled, a middleware injects a hot reload script into the response HTML.
+ // We don't want the browser to bypass this injection by using a cached response that doesn't
+ // contain the injected script. In the future, if script injection is removed in favor of a
+ // different mechanism, we can delete this comment and the line below it.
+ // See also: https://github.com/dotnet/aspnetcore/issues/45213
+ fileContext.Context.Response.Headers[HeaderNames.CacheControl] = "no-store";
+
if (applyCopHeaders)
{
// Browser multi-threaded runtime requires cross-origin policy headers to enable SharedArrayBuffer.
diff --git a/src/Components/WebView/WebView/src/build/Microsoft.AspNetCore.Components.WebView.props b/src/Components/WebView/WebView/src/build/Microsoft.AspNetCore.Components.WebView.props
index 15ea80456007..7a786d833426 100644
--- a/src/Components/WebView/WebView/src/build/Microsoft.AspNetCore.Components.WebView.props
+++ b/src/Components/WebView/WebView/src/build/Microsoft.AspNetCore.Components.WebView.props
@@ -29,7 +29,10 @@
<_WebViewAssetCandidates Remove="@(_MissingWebViewAssetCandidates)" />
-
+