Skip to content

Commit 21314b6

Browse files
committed
Feedback - server
1 parent bfa8145 commit 21314b6

File tree

7 files changed

+10
-58
lines changed

7 files changed

+10
-58
lines changed

src/Components/Components/src/IEndpointHtmlRenderer.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#nullable enable
2-
Microsoft.AspNetCore.Components.IEndpointHtmlRenderer
3-
Microsoft.AspNetCore.Components.IEndpointHtmlRenderer.SetNotFoundResponse() -> void
42
Microsoft.AspNetCore.Components.NavigationManager.NotFoundEvent -> System.EventHandler<System.EventArgs!>!
5-
Microsoft.AspNetCore.Components.Routing.IHostEnvironmentNavigationManager.Initialize(string! baseUri, string! uri, Microsoft.AspNetCore.Components.IEndpointHtmlRenderer! renderer) -> void
63
virtual Microsoft.AspNetCore.Components.NavigationManager.NotFound() -> void
74
virtual Microsoft.AspNetCore.Components.NavigationManager.NotFoundCore() -> void

src/Components/Components/src/Routing/IHostEnvironmentNavigationManager.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,4 @@ public interface IHostEnvironmentNavigationManager
1515
/// <param name="baseUri">The base URI.</param>
1616
/// <param name="uri">The absolute URI.</param>
1717
void Initialize(string baseUri, string uri);
18-
19-
/// <summary>
20-
/// Initializes the <see cref="NavigationManager" />.
21-
/// </summary>
22-
/// <param name="baseUri">The base URI.</param>
23-
/// <param name="uri">The absolute URI.</param>
24-
/// <param name="renderer">The renderer.</param>
25-
void Initialize(string baseUri, string uri, IEndpointHtmlRenderer renderer);
2618
}

src/Components/Endpoints/src/DependencyInjection/HttpNavigationManager.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,11 @@ namespace Microsoft.AspNetCore.Components.Endpoints;
77

88
internal sealed class HttpNavigationManager : NavigationManager, IHostEnvironmentNavigationManager
99
{
10-
private IEndpointHtmlRenderer? _renderer;
11-
1210
void IHostEnvironmentNavigationManager.Initialize(string baseUri, string uri) => Initialize(baseUri, uri);
1311

14-
void IHostEnvironmentNavigationManager.Initialize(string baseUri, string uri, IEndpointHtmlRenderer? renderer)
15-
{
16-
Initialize(baseUri, uri);
17-
_renderer = renderer;
18-
}
19-
2012
protected override void NavigateToCore(string uri, NavigationOptions options)
2113
{
2214
var absoluteUriString = ToAbsoluteUri(uri).AbsoluteUri;
2315
throw new NavigationException(absoluteUriString);
2416
}
25-
26-
protected override void NotFoundCore()
27-
{
28-
_renderer?.SetNotFoundResponse();
29-
}
3017
}

src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Components.Endpoints;
3535
/// output with prerendering markers so the content can later switch into interactive mode when used with
3636
/// blazor.*.js. It also deals with initializing the standard component DI services once per request.
3737
/// </summary>
38-
internal partial class EndpointHtmlRenderer : StaticHtmlRenderer, IComponentPrerenderer, IEndpointHtmlRenderer
38+
internal partial class EndpointHtmlRenderer : StaticHtmlRenderer, IComponentPrerenderer
3939
{
4040
private readonly IServiceProvider _services;
4141
private readonly RazorComponentsServiceOptions _options;
@@ -77,7 +77,15 @@ internal async Task InitializeStandardComponentServicesAsync(
7777
IFormCollection? form = null)
7878
{
7979
var navigationManager = (IHostEnvironmentNavigationManager)httpContext.RequestServices.GetRequiredService<NavigationManager>();
80-
navigationManager?.Initialize(GetContextBaseUri(httpContext.Request), GetFullUri(httpContext.Request), this);
80+
navigationManager?.Initialize(GetContextBaseUri(httpContext.Request), GetFullUri(httpContext.Request));
81+
82+
if (navigationManager is HttpNavigationManager httpNavigationManager)
83+
{
84+
httpNavigationManager.NotFoundEvent += (sender, args) =>
85+
{
86+
SetNotFoundResponse();
87+
};
88+
}
8189

8290
var authenticationStateProvider = httpContext.RequestServices.GetService<AuthenticationStateProvider>();
8391
if (authenticationStateProvider is IHostEnvironmentAuthenticationStateProvider hostEnvironmentAuthenticationStateProvider)

src/Components/Endpoints/test/RazorComponentResultTest.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -513,11 +513,6 @@ class FakeNavigationManager : NavigationManager, IHostEnvironmentNavigationManag
513513
public new void Initialize(string baseUri, string uri)
514514
=> base.Initialize(baseUri, uri);
515515

516-
#nullable enable
517-
public void Initialize(string baseUri, string uri, IEndpointHtmlRenderer? renderer = null)
518-
=> base.Initialize(baseUri, uri);
519-
#nullable disable
520-
521516
protected override void NavigateToCore(string uri, NavigationOptions options)
522517
{
523518
// Equivalent to what RemoteNavigationManager would do

src/Components/Server/src/Circuits/RemoteNavigationManager.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,6 @@ public RemoteNavigationManager(ILogger<RemoteNavigationManager> logger)
4545
NotifyLocationChanged(isInterceptedLink: false);
4646
}
4747

48-
/// <summary>
49-
/// Initializes the <see cref="NavigationManager" />.
50-
/// </summary>
51-
/// <param name="baseUri">The base URI.</param>
52-
/// <param name="uri">The absolute URI.</param>
53-
/// <param name="renderer">The optional renderer.</param>
54-
public void Initialize(string baseUri, string uri, IEndpointHtmlRenderer? renderer = null)
55-
{
56-
base.Initialize(baseUri, uri);
57-
NotifyLocationChanged(isInterceptedLink: false);
58-
}
59-
6048
/// <summary>
6149
/// Initializes the <see cref="RemoteNavigationManager"/>.
6250
/// </summary>

0 commit comments

Comments
 (0)