dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.36k stars 9.99k forks source link

Cancellation support for StreamRendering #51838

Open davhdavh opened 11 months ago

davhdavh commented 11 months ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe the problem.

50733 implemented the cancellation of the serverside streamrendering on navigation.

However, there does not seem to be a way to trigger cancellation from the user.

Describe the solution you'd like

IE, the scenario is to have a cancel button that will just trigger the AbortController (currentEnhancedNavigationAbortController in https://github.com/dotnet/aspnetcore/blob/main/src/Components/Web.JS/src/Services/NavigationEnhancement.ts).

@attribute [StreamRendering]
<EditForm Model="MyModel" Enhance="true" FormName="someform" OnValidSubmit="OnValidSubmit">
...
<button disabled="@(!_submitting)" ...>Abort request</button> <!--- <<<<< HERE <<<<< --->
</EditForm>

   [CascadingParameter]
   public HttpContext HttpContext { get; set; } = default!;
   private async Task OnValidSubmit()
   {
      _submitting = true;
      try
      {
         await Task.Delay(TimeSpan.FromSeconds(10), HttpContext?.RequestAborted ?? default);
      } catch (TaskCanceledException e) {
         logger.LogInformation("Cancelled");
         throw;
      }
      _submitting = false;
      _submitted = true;
  }

Additional context

No response

ghost commented 11 months ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.