Skip to content

Commit 8d690b4

Browse files
JamesNKadamint
andauthored
serve blazor.web.js from wwwroot instead of setting up new endpoint to serve it (#10990)
Co-authored-by: Adam Ratzman <adam@adamratzman.com>
1 parent 9c400db commit 8d690b4

File tree

8 files changed

+3
-53
lines changed

8 files changed

+3
-53
lines changed

Directory.Packages.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@
212212
<PackageVersion Update="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="$(MicrosoftExtensionsDiagnosticsHealthChecksEntityFrameworkCoreVersion)" />
213213
<PackageVersion Update="Microsoft.Extensions.Diagnostics.HealthChecks" Version="$(MicrosoftExtensionsDiagnosticsHealthChecksVersion)" />
214214
<PackageVersion Update="Microsoft.Extensions.Features" Version="$(MicrosoftExtensionsFeaturesVersion)" />
215-
<PackageVersion Update="Microsoft.Extensions.FileProviders.Embedded" Version="$(MicrosoftExtensionsFileProvidersEmbeddedVersion)" />
216215
<PackageVersion Update="Microsoft.AspNetCore.SignalR.Client" Version="$(MicrosoftAspNetCoreSignalRClientVersion)" />
217216
<!-- Runtime -->
218217
<PackageVersion Update="Microsoft.Extensions.Hosting.Abstractions" Version="$(MicrosoftExtensionsHostingAbstractionsVersion)" />

eng/Versions.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
<MicrosoftExtensionsDiagnosticsHealthChecksEntityFrameworkCoreVersion>9.0.7</MicrosoftExtensionsDiagnosticsHealthChecksEntityFrameworkCoreVersion>
7272
<MicrosoftExtensionsDiagnosticsHealthChecksVersion>9.0.7</MicrosoftExtensionsDiagnosticsHealthChecksVersion>
7373
<MicrosoftExtensionsFeaturesVersion>9.0.7</MicrosoftExtensionsFeaturesVersion>
74-
<MicrosoftExtensionsFileProvidersEmbeddedVersion>9.0.7</MicrosoftExtensionsFileProvidersEmbeddedVersion>
7574
<MicrosoftAspNetCoreSignalRClientVersion>9.0.7</MicrosoftAspNetCoreSignalRClientVersion>
7675
<!-- Runtime -->
7776
<MicrosoftExtensionsHostingAbstractionsVersion>9.0.7</MicrosoftExtensionsHostingAbstractionsVersion>

src/Aspire.Dashboard/Aspire.Dashboard.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
<RollForward>Major</RollForward>
2020

2121
<DefineConstants>$(DefineConstants);ASPIRE_DASHBOARD</DefineConstants>
22-
23-
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
2422
</PropertyGroup>
2523

2624
<PropertyGroup>
@@ -37,8 +35,6 @@
3735
<Protobuf Include="..\Aspire.Hosting\Dashboard\proto\dashboard_service.proto">
3836
<Link>ServiceClient\dashboard_service.proto</Link>
3937
</Protobuf>
40-
41-
<EmbeddedResource Include="Embedded\blazor.web.js" LogicalName="_aspire/blazor.web.js" />
4238
</ItemGroup>
4339

4440
<!-- Used by publishing infrastructure to get the version to use for blob publishing -->
@@ -50,7 +46,6 @@
5046
<PackageReference Include="Markdig" />
5147
<PackageReference Include="Microsoft.AspNetCore.Authentication.Certificate" />
5248
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" />
53-
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" />
5449
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components" />
5550
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components.Icons" />
5651
</ItemGroup>

src/Aspire.Dashboard/Components/App.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
<Routes @rendermode="@(new InteractiveServerRenderMode(prerender: false))" />
3030
<ReconnectModal />
3131
@*
32-
Use Blazor JS embedded in dashboard. This is done because the dashboard is currently built for .NET 8, and in .NET 8 the Blazor JS is embedded in the components assembly.
32+
Use Blazor JS shipped in dashboard's wwwroot. This is done because the dashboard is currently built for .NET 8, and in .NET 8 the Blazor JS is embedded in the components assembly.
3333
But in .NET 10 and later the Blazor JS file is an asset. We can rely on Blazor JS always being available. Remove and use asset file in the future once .NET 10 is the minimum version.
3434
This file is copied from .NET 10 P4.
3535
*@
36-
<script src="_aspire/blazor.web.js"></script>
36+
<script src="framework/blazor.web.js"></script>
3737
<script src="js/app.js"></script>
3838
<script src="js/app-reconnect.js"></script>
3939

src/Aspire.Dashboard/DashboardEndpointsBuilder.cs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,54 +8,12 @@
88
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
99
using Microsoft.AspNetCore.Localization;
1010
using Microsoft.AspNetCore.Mvc;
11-
using Microsoft.AspNetCore.StaticFiles;
12-
using Microsoft.Extensions.FileProviders;
1311
using Microsoft.Extensions.Options;
14-
using Microsoft.Net.Http.Headers;
1512

1613
namespace Aspire.Dashboard;
1714

1815
public static class DashboardEndpointsBuilder
1916
{
20-
public static void MapDashboardBlazor(this IEndpointRouteBuilder endpoints)
21-
{
22-
var options = new StaticFileOptions
23-
{
24-
FileProvider = new ManifestEmbeddedFileProvider(typeof(DashboardEndpointsBuilder).Assembly),
25-
OnPrepareResponse = SetCacheHeaders
26-
};
27-
28-
var app = endpoints.CreateApplicationBuilder();
29-
app.Use(next => context =>
30-
{
31-
// Set endpoint to null so the static files middleware will handle the request.
32-
context.SetEndpoint(null);
33-
34-
return next(context);
35-
});
36-
app.UseStaticFiles(options);
37-
38-
endpoints.MapGet("/_aspire/blazor.web.js", app.Build());
39-
40-
static void SetCacheHeaders(StaticFileResponseContext ctx)
41-
{
42-
// By setting "Cache-Control: no-cache", we're allowing the browser to store
43-
// a cached copy of the response, but telling it that it must check with the
44-
// server for modifications (based on Etag) before using that cached copy.
45-
// Longer term, we should generate URLs based on content hashes (at least
46-
// for published apps) so that the browser doesn't need to make any requests
47-
// for unchanged files.
48-
var headers = ctx.Context.Response.GetTypedHeaders();
49-
if (headers.CacheControl == null)
50-
{
51-
headers.CacheControl = new CacheControlHeaderValue
52-
{
53-
NoCache = true
54-
};
55-
}
56-
}
57-
}
58-
5917
public static void MapDashboardHealthChecks(this IEndpointRouteBuilder endpoints)
6018
{
6119
endpoints.MapHealthChecks($"/{DashboardUrls.HealthBasePath}").AllowAnonymous();

src/Aspire.Dashboard/DashboardWebApplication.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,6 @@ public DashboardWebApplication(
444444

445445
_app.MapDashboardApi(dashboardOptions);
446446
_app.MapDashboardHealthChecks();
447-
_app.MapDashboardBlazor();
448447
}
449448

450449
private ILogger<DashboardWebApplication> GetLogger()

src/Aspire.Dashboard/Embedded/blazor.web.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/Aspire.Dashboard/wwwroot/framework/blazor.web.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)