Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Blazor] Adds compresion support for all assets in an application #55558

Merged
merged 13 commits into from
May 13, 2024
41 changes: 41 additions & 0 deletions AspNetCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -1806,6 +1806,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.OpenAp
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KeyManagementSimulator", "src\DataProtection\samples\KeyManagementSimulator\KeyManagementSimulator.csproj", "{5B5F86CC-3598-463C-9F9B-F78FBB6642F4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "StaticAssets", "StaticAssets", "{274100A5-5B2D-4EA2-AC42-A62257FC6BDC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.StaticAssets", "src\StaticAssets\src\Microsoft.AspNetCore.StaticAssets.csproj", "{4D8DE54A-4F32-4881-B07B-DDC79619E573}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.StaticAssets.Tests", "src\StaticAssets\test\Microsoft.AspNetCore.StaticAssets.Tests.csproj", "{9536C284-65B4-4884-BB50-06D629095C3E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -10903,6 +10909,38 @@ Global
{5B5F86CC-3598-463C-9F9B-F78FBB6642F4}.Release|x64.Build.0 = Release|Any CPU
{5B5F86CC-3598-463C-9F9B-F78FBB6642F4}.Release|x86.ActiveCfg = Release|Any CPU
{5B5F86CC-3598-463C-9F9B-F78FBB6642F4}.Release|x86.Build.0 = Release|Any CPU
{4D8DE54A-4F32-4881-B07B-DDC79619E573}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D8DE54A-4F32-4881-B07B-DDC79619E573}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D8DE54A-4F32-4881-B07B-DDC79619E573}.Debug|arm64.ActiveCfg = Debug|Any CPU
{4D8DE54A-4F32-4881-B07B-DDC79619E573}.Debug|arm64.Build.0 = Debug|Any CPU
{4D8DE54A-4F32-4881-B07B-DDC79619E573}.Debug|x64.ActiveCfg = Debug|Any CPU
{4D8DE54A-4F32-4881-B07B-DDC79619E573}.Debug|x64.Build.0 = Debug|Any CPU
{4D8DE54A-4F32-4881-B07B-DDC79619E573}.Debug|x86.ActiveCfg = Debug|Any CPU
{4D8DE54A-4F32-4881-B07B-DDC79619E573}.Debug|x86.Build.0 = Debug|Any CPU
{4D8DE54A-4F32-4881-B07B-DDC79619E573}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D8DE54A-4F32-4881-B07B-DDC79619E573}.Release|Any CPU.Build.0 = Release|Any CPU
{4D8DE54A-4F32-4881-B07B-DDC79619E573}.Release|arm64.ActiveCfg = Release|Any CPU
{4D8DE54A-4F32-4881-B07B-DDC79619E573}.Release|arm64.Build.0 = Release|Any CPU
{4D8DE54A-4F32-4881-B07B-DDC79619E573}.Release|x64.ActiveCfg = Release|Any CPU
{4D8DE54A-4F32-4881-B07B-DDC79619E573}.Release|x64.Build.0 = Release|Any CPU
{4D8DE54A-4F32-4881-B07B-DDC79619E573}.Release|x86.ActiveCfg = Release|Any CPU
{4D8DE54A-4F32-4881-B07B-DDC79619E573}.Release|x86.Build.0 = Release|Any CPU
{9536C284-65B4-4884-BB50-06D629095C3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9536C284-65B4-4884-BB50-06D629095C3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9536C284-65B4-4884-BB50-06D629095C3E}.Debug|arm64.ActiveCfg = Debug|Any CPU
{9536C284-65B4-4884-BB50-06D629095C3E}.Debug|arm64.Build.0 = Debug|Any CPU
{9536C284-65B4-4884-BB50-06D629095C3E}.Debug|x64.ActiveCfg = Debug|Any CPU
{9536C284-65B4-4884-BB50-06D629095C3E}.Debug|x64.Build.0 = Debug|Any CPU
{9536C284-65B4-4884-BB50-06D629095C3E}.Debug|x86.ActiveCfg = Debug|Any CPU
{9536C284-65B4-4884-BB50-06D629095C3E}.Debug|x86.Build.0 = Debug|Any CPU
{9536C284-65B4-4884-BB50-06D629095C3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9536C284-65B4-4884-BB50-06D629095C3E}.Release|Any CPU.Build.0 = Release|Any CPU
{9536C284-65B4-4884-BB50-06D629095C3E}.Release|arm64.ActiveCfg = Release|Any CPU
{9536C284-65B4-4884-BB50-06D629095C3E}.Release|arm64.Build.0 = Release|Any CPU
{9536C284-65B4-4884-BB50-06D629095C3E}.Release|x64.ActiveCfg = Release|Any CPU
{9536C284-65B4-4884-BB50-06D629095C3E}.Release|x64.Build.0 = Release|Any CPU
{9536C284-65B4-4884-BB50-06D629095C3E}.Release|x86.ActiveCfg = Release|Any CPU
{9536C284-65B4-4884-BB50-06D629095C3E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -11795,6 +11833,9 @@ Global
{9DC6B242-457B-4767-A84B-C3D23B76C642} = {2299CCD8-8F9C-4F2B-A633-9BF4DA81022B}
{D53F0EF7-0CDC-49B4-AA2D-229901B0A734} = {9DC6B242-457B-4767-A84B-C3D23B76C642}
{5B5F86CC-3598-463C-9F9B-F78FBB6642F4} = {8275510E-0E6C-45A8-99DF-4F106BC7F075}
{274100A5-5B2D-4EA2-AC42-A62257FC6BDC} = {017429CC-C5FB-48B4-9C46-034E29EE2F06}
{4D8DE54A-4F32-4881-B07B-DDC79619E573} = {274100A5-5B2D-4EA2-AC42-A62257FC6BDC}
{9536C284-65B4-4884-BB50-06D629095C3E} = {274100A5-5B2D-4EA2-AC42-A62257FC6BDC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3E8720B3-DBDD-498C-B383-2CC32A054E8F}
Expand Down
2 changes: 2 additions & 0 deletions eng/Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
$(RepoRoot)src\Mvc\**\*.*proj;
$(RepoRoot)src\Azure\**\*.*proj;
$(RepoRoot)src\SignalR\**\*.csproj;
$(RepoRoot)src\StaticAssets\**\*.csproj;
$(RepoRoot)src\Components\**\*.csproj;
$(RepoRoot)src\Analyzers\**\*.csproj;
$(RepoRoot)src\FileProviders\**\*.csproj;
Expand Down Expand Up @@ -219,6 +220,7 @@
$(RepoRoot)src\Mvc\**\src\*.csproj;
$(RepoRoot)src\Azure\**\src\*.csproj;
$(RepoRoot)src\SignalR\**\src\*.csproj;
$(RepoRoot)src\StaticAssets\src\*.csproj;
$(RepoRoot)src\Components\**\src\*.csproj;
$(RepoRoot)src\FileProviders\**\src\*.csproj;
$(RepoRoot)src\Configuration.KeyPerFile\**\src\*.csproj;
Expand Down
1 change: 1 addition & 0 deletions eng/ProjectReferences.props
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
<ProjectReferenceProvider Include="Microsoft.AspNetCore.SignalR" ProjectPath="$(RepoRoot)src\SignalR\server\SignalR\src\Microsoft.AspNetCore.SignalR.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.SignalR.Specification.Tests" ProjectPath="$(RepoRoot)src\SignalR\server\Specification.Tests\src\Microsoft.AspNetCore.SignalR.Specification.Tests.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" ProjectPath="$(RepoRoot)src\SignalR\server\StackExchangeRedis\src\Microsoft.AspNetCore.SignalR.StackExchangeRedis.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.StaticAssets" ProjectPath="$(RepoRoot)src\StaticAssets\src\Microsoft.AspNetCore.StaticAssets.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Components.Authorization" ProjectPath="$(RepoRoot)src\Components\Authorization\src\Microsoft.AspNetCore.Components.Authorization.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Components" ProjectPath="$(RepoRoot)src\Components\Components\src\Microsoft.AspNetCore.Components.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Components.CustomElements" ProjectPath="$(RepoRoot)src\Components\CustomElements\src\Microsoft.AspNetCore.Components.CustomElements.csproj" />
Expand Down
1 change: 1 addition & 0 deletions eng/SharedFramework.Local.props
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<AspNetCoreAppReference Include="Microsoft.AspNetCore.Http.Connections" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.SignalR.Core" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.SignalR" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.StaticAssets" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.Components.Endpoints" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.Components.Server" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions eng/ShippingAssemblies.props
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
<AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.SignalR.Common" />
<AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.SignalR.Core" />
<AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.SignalR" />
<AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.StaticAssets" />
<AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Components.Authorization" />
<AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Components" />
<AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Components.Endpoints" />
Expand Down
1 change: 1 addition & 0 deletions eng/TrimmableProjects.props
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
<TrimmableProject Include="Microsoft.AspNetCore.Http.Connections.Common" />
<TrimmableProject Include="Microsoft.AspNetCore.Http.Connections" />
<TrimmableProject Include="Microsoft.AspNetCore.SignalR.Common" />
<TrimmableProject Include="Microsoft.AspNetCore.StaticAssets" />
<TrimmableProject Include="Microsoft.AspNetCore.Components.Authorization" />
<TrimmableProject Include="Microsoft.AspNetCore.Components" />
<TrimmableProject Include="Microsoft.AspNetCore.Components.CustomElements" />
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"sdk": {
"version": "9.0.100-preview.5.24229.2"
"version": "9.0.100-preview.5.24253.17"
},
"tools": {
"dotnet": "9.0.100-preview.5.24229.2",
"dotnet": "9.0.100-preview.5.24253.17",
"runtimes": {
"dotnet/x86": [
"$(MicrosoftNETCoreBrowserDebugHostTransportVersion)"
Expand Down
5 changes: 5 additions & 0 deletions src/Components/Components.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"src\\Components\\WebAssembly\\Authentication.Msal\\src\\Microsoft.Authentication.WebAssembly.Msal.csproj",
"src\\Components\\WebAssembly\\DevServer\\src\\Microsoft.AspNetCore.Components.WebAssembly.DevServer.csproj",
"src\\Components\\WebAssembly\\JSInterop\\src\\Microsoft.JSInterop.WebAssembly.csproj",
"src\\Components\\WebAssembly\\Samples\\HostedBlazorWebassemblyApp\\Client\\HostedBlazorWebassemblyApp.Client.csproj",
"src\\Components\\WebAssembly\\Samples\\HostedBlazorWebassemblyApp\\Server\\HostedBlazorWebassemblyApp.Server.csproj",
"src\\Components\\WebAssembly\\Samples\\HostedBlazorWebassemblyApp\\Shared\\HostedBlazorWebassemblyApp.Shared.csproj",
"src\\Components\\WebAssembly\\Server\\src\\Microsoft.AspNetCore.Components.WebAssembly.Server.csproj",
"src\\Components\\WebAssembly\\Server\\test\\Microsoft.AspNetCore.Components.WebAssembly.Server.Tests.csproj",
"src\\Components\\WebAssembly\\WebAssembly.Authentication\\src\\Microsoft.AspNetCore.Components.WebAssembly.Authentication.csproj",
Expand Down Expand Up @@ -145,6 +148,8 @@
"src\\SignalR\\common\\SignalR.Common\\src\\Microsoft.AspNetCore.SignalR.Common.csproj",
"src\\SignalR\\server\\Core\\src\\Microsoft.AspNetCore.SignalR.Core.csproj",
"src\\SignalR\\server\\SignalR\\src\\Microsoft.AspNetCore.SignalR.csproj",
"src\\StaticAssets\\src\\Microsoft.AspNetCore.StaticAssets.csproj",
"src\\StaticAssets\\test\\Microsoft.AspNetCore.StaticAssets.Tests.csproj",
"src\\Testing\\src\\Microsoft.AspNetCore.InternalTesting.csproj",
"src\\WebEncoders\\src\\Microsoft.Extensions.WebEncoders.csproj"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;

namespace Microsoft.AspNetCore.Components.Endpoints.Infrastructure;

Expand All @@ -19,5 +20,11 @@ public static void AddRenderMode(RazorComponentsEndpointConventionBuilder builde
{
builder.AddRenderMode(renderMode);
}

/// <summary>
/// This method is not recommended for use outside of the Blazor framework.
/// </summary>
/// <param name="builder"></param>
javiercn marked this conversation as resolved.
Show resolved Hide resolved
public static IEndpointRouteBuilder GetEndpointRouteBuilder(RazorComponentsEndpointConventionBuilder builder) => builder.EndpointRouteBuilder;
}

Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,20 @@ internal class RazorComponentEndpointDataSource<[DynamicallyAccessedMembers(Comp
public RazorComponentEndpointDataSource(
ComponentApplicationBuilder builder,
IEnumerable<RenderModeEndpointProvider> renderModeEndpointProviders,
IApplicationBuilder applicationBuilder,
IEndpointRouteBuilder endpointRouteBuilder,
RazorComponentEndpointFactory factory,
HotReloadService? hotReloadService = null)
{
_builder = builder;
_applicationBuilder = applicationBuilder;
_applicationBuilder = endpointRouteBuilder.CreateApplicationBuilder();
_renderModeEndpointProviders = renderModeEndpointProviders.ToArray();
_factory = factory;
_hotReloadService = hotReloadService;
HotReloadService.ClearCacheEvent += OnHotReloadClearCache;
DefaultBuilder = new RazorComponentsEndpointConventionBuilder(
_lock,
builder,
endpointRouteBuilder,
_options,
_conventions,
_finallyConventions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ internal class RazorComponentEndpointDataSourceFactory
var builder = ComponentApplicationBuilder.GetBuilder<TRootComponent>() ??
DefaultRazorComponentApplication<TRootComponent>.Instance.GetBuilder();

return new RazorComponentEndpointDataSource<TRootComponent>(builder, _providers, endpoints.CreateApplicationBuilder(), _factory, _hotReloadService);
return new RazorComponentEndpointDataSource<TRootComponent>(builder, _providers, endpoints, _factory, _hotReloadService);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Discovery;
using Microsoft.AspNetCore.Components.Endpoints;
using Microsoft.AspNetCore.Routing;

namespace Microsoft.AspNetCore.Builder;

Expand All @@ -14,19 +15,22 @@ public sealed class RazorComponentsEndpointConventionBuilder : IEndpointConventi
{
private readonly object _lock;
private readonly ComponentApplicationBuilder _builder;
private readonly IEndpointRouteBuilder _endpointRouteBuilder;
private readonly RazorComponentDataSourceOptions _options;
private readonly List<Action<EndpointBuilder>> _conventions;
private readonly List<Action<EndpointBuilder>> _finallyConventions;

internal RazorComponentsEndpointConventionBuilder(
object @lock,
ComponentApplicationBuilder builder,
IEndpointRouteBuilder endpointRouteBuilder,
RazorComponentDataSourceOptions options,
List<Action<EndpointBuilder>> conventions,
List<Action<EndpointBuilder>> finallyConventions)
{
_lock = @lock;
_builder = builder;
_endpointRouteBuilder = endpointRouteBuilder;
_options = options;
_conventions = conventions;
_finallyConventions = finallyConventions;
Expand All @@ -37,6 +41,8 @@ public sealed class RazorComponentsEndpointConventionBuilder : IEndpointConventi
/// </summary>
internal ComponentApplicationBuilder ApplicationBuilder => _builder;

internal IEndpointRouteBuilder EndpointRouteBuilder => _endpointRouteBuilder;

/// <inheritdoc/>
public void Add(Action<EndpointBuilder> convention)
{
Expand Down
1 change: 1 addition & 0 deletions src/Components/Endpoints/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#nullable enable
Microsoft.AspNetCore.Components.Routing.RazorComponentsEndpointHttpContextExtensions
static Microsoft.AspNetCore.Components.Endpoints.Infrastructure.ComponentEndpointConventionBuilderHelper.GetEndpointRouteBuilder(Microsoft.AspNetCore.Builder.RazorComponentsEndpointConventionBuilder! builder) -> Microsoft.AspNetCore.Routing.IEndpointRouteBuilder!
static Microsoft.AspNetCore.Components.Routing.RazorComponentsEndpointHttpContextExtensions.AcceptsInteractiveRouting(this Microsoft.AspNetCore.Http.HttpContext! context) -> bool
16 changes: 15 additions & 1 deletion src/Components/Endpoints/test/HotReloadServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private IServiceProvider CreateServices(params Type[] types)
var result = new RazorComponentEndpointDataSource<TComponent>(
builder,
new[] { new MockEndpointProvider() },
new ApplicationBuilder(services),
new TestEndpointRouteBuilder(services),
new RazorComponentEndpointFactory(),
new HotReloadService() { MetadataUpdateSupported = true });

Expand Down Expand Up @@ -256,4 +256,18 @@ public override IEnumerable<RouteEndpointBuilder> GetEndpointBuilders(IComponent

public override bool Supports(IComponentRenderMode renderMode) => true;
}

private class TestEndpointRouteBuilder : IEndpointRouteBuilder
{
private IServiceProvider _serviceProvider;
private List<EndpointDataSource> _dataSources = new();

public TestEndpointRouteBuilder(IServiceProvider serviceProvider) => _serviceProvider = serviceProvider;

public IServiceProvider ServiceProvider => _serviceProvider;

public ICollection<EndpointDataSource> DataSources => _dataSources;

public IApplicationBuilder CreateApplicationBuilder() => new ApplicationBuilder(_serviceProvider);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private IServiceProvider CreateServices(params Type[] types)
var result = new RazorComponentEndpointDataSource<TComponent>(
builder ?? DefaultRazorComponentApplication<TComponent>.Instance.GetBuilder(),
services?.GetService<IEnumerable<RenderModeEndpointProvider>>() ?? Enumerable.Empty<RenderModeEndpointProvider>(),
new ApplicationBuilder(services ?? new ServiceCollection().BuildServiceProvider()),
new TestEndpointRouteBuilder(services ?? new ServiceCollection().BuildServiceProvider()),
new RazorComponentEndpointFactory(),
new HotReloadService() { MetadataUpdateSupported = true });

Expand Down Expand Up @@ -277,6 +277,20 @@ public override IEnumerable<RouteEndpointBuilder> GetEndpointBuilders(IComponent

public override bool Supports(IComponentRenderMode renderMode) => renderMode is InteractiveWebAssemblyRenderMode or InteractiveAutoRenderMode;
}

private class TestEndpointRouteBuilder : IEndpointRouteBuilder
{
private IServiceProvider _serviceProvider;
private List<EndpointDataSource> _dataSources = new();

public TestEndpointRouteBuilder(IServiceProvider serviceProvider) => _serviceProvider = serviceProvider;

public IServiceProvider ServiceProvider => _serviceProvider;

public ICollection<EndpointDataSource> DataSources => _dataSources;

public IApplicationBuilder CreateApplicationBuilder() => new ApplicationBuilder(_serviceProvider);
}
}

public class App : IComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Reference Include="Microsoft.AspNetCore.Components.Server" />
<Reference Include="Microsoft.AspNetCore.HttpsPolicy" />
<Reference Include="Microsoft.AspNetCore.StaticFiles" />
<Reference Include="Microsoft.AspNetCore.StaticAssets" />
<Reference Include="Microsoft.AspNetCore.Mvc" />
</ItemGroup>

Expand Down
1 change: 1 addition & 0 deletions src/Components/Samples/BlazorUnitedApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
app.UseStaticFiles();
app.UseAntiforgery();

app.MapStaticAssets();
javiercn marked this conversation as resolved.
Show resolved Hide resolved
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<Reference Include="Microsoft.AspNetCore" />
<Reference Include="Microsoft.AspNetCore.HttpsPolicy" />
<Reference Include="Microsoft.AspNetCore.Mvc" />
<Reference Include="Microsoft.AspNetCore.StaticAssets" />
<Reference Include="Microsoft.Extensions.Hosting" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using HostedBlazorWebassemblyApp.Server.Data;
using HostedBlazorWebassemblyApp.Shared;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Components.WebAssembly.Server;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.Extensions.Configuration;
Expand Down Expand Up @@ -48,16 +49,14 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
}

app.UseHttpsRedirection();
app.UseBlazorFrameworkFiles();
app.UseStaticFiles();

app.UseRouting();

app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
endpoints.MapControllers();
//endpoints.MapFallbackToFile("index.html");
endpoints.MapStaticAssets();
endpoints.MapFallbackToPage("/_Host");
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ public sealed class WebAssemblyComponentsEndpointOptions
/// information, see <see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements" />.
/// </summary>
public bool ServeMultithreadingHeaders { get; set; }

/// <summary>
/// Gets or sets the <see cref="string"/> that determines the static assets manifest path mapped to this app.
/// </summary>
public string? StaticAssetsManifestPath { get; set; }

internal bool ConventionsApplied { get; set; }
}
Loading
Loading