Skip to content

Commit f7c6092

Browse files
committed
Feedback: neat POST detection and redundant awaits removal.
1 parent 41a186c commit f7c6092

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ internal async Task SetNotFoundResponseAsync(string baseUri, NotFoundEventArgs a
8484
if (_httpContext.Response.HasStarted ||
8585
// POST waits for quiescence -> rendering the NotFoundPage would be queued for the next batch
8686
// but we want to send the signal to the renderer to stop rendering future batches -> use client rendering
87-
string.Equals(_httpContext.Request.Method, "POST", StringComparison.OrdinalIgnoreCase))
87+
HttpMethods.IsPost(_httpContext.Request.Method))
8888
{
8989
if (string.IsNullOrEmpty(_notFoundUrl))
9090
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ private static void HandleNavigationAfterResponseStarted(TextWriter writer, Http
240240

241241
private static void WriteResponseTemplate(TextWriter writer, HttpContext httpContext, string destinationUrl)
242242
{
243-
if (string.Equals(httpContext.Request.Method, "POST", StringComparison.OrdinalIgnoreCase))
243+
if (HttpMethods.IsPost(httpContext.Request.Method))
244244
{
245245
writer.Write(" from=\"form-post\"");
246246
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,10 @@ internal async Task InitializeStandardComponentServicesAsync(
8585
var navigationManager = httpContext.RequestServices.GetRequiredService<NavigationManager>();
8686
((IHostEnvironmentNavigationManager)navigationManager)?.Initialize(GetContextBaseUri(httpContext.Request), GetFullUri(httpContext.Request), OnNavigateTo);
8787

88-
if (navigationManager != null)
88+
navigationManager?.OnNotFound += (sender, args) =>
8989
{
90-
navigationManager.OnNotFound += async (sender, args) =>
91-
await GetErrorHandledTask(SetNotFoundResponseAsync(navigationManager.BaseUri, args));
92-
}
90+
_ = GetErrorHandledTask(SetNotFoundResponseAsync(navigationManager.BaseUri, args));
91+
};
9392

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

0 commit comments

Comments
 (0)