Cancellation support for StreamRendering
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### 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).
```csharp
@attribute [StreamRendering]
...
Abort request
[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_
Contributor guide
Assessment
This issue has not been assessed yet.