Can't cancel task in Asp.net core Action
Asked Answered
F

1

7

I am trying to cancel Task running in Asp.net Core Action. For that I am using this github sample. I can cancel task if running service in console, but if I run under IIS (or IIS Express) task is not canceling. I saw similar issue in other question. Based on it issue should be fixed already. I am using .Net core 2.1.

Furiya answered 5/6, 2018 at 14:12 Comment(7)
Get clear what you mean with "cancel it"? Do you want to cancel the operation when the connection is lost (ie caller closed the connection or hit abort button in the browser)? Then pass HttpContext.RequestAborted to your async methods (its an cancellation token). If not how oyu intend user to cancel it?Stockdale
I am aborting request from client using javascript or from WPF client calling Task.Cancel() and passing CancellationToken to service callFuriya
Did you try the above? This is the way is supposed to work. It's an cancellation tokenStockdale
My issue is that HttpContext.RequestAborted.IsCancellationRequested is false, but action is aborted from clientFuriya
When I use Kestrel as server it is working, but when server is IIS it is not workingFuriya
Did you try if its still an issue with ASP.NET Core 2.1 in process hosting? blogs.msdn.microsoft.com/webdev/2018/02/28/…Stockdale
I will try laterFuriya
R
8

As I know this is known issue and doesn't fixed yet. See more details on ANCM project page.

Rodie answered 5/6, 2018 at 15:29 Comment(4)
I was hoping this is fixed after 2 years :) Thanks for response.Furiya
Push MS team once more to be more productive :)Rodie
Same issue here: #50110601 . I asked the MS team about it as well...tumbleweeds.Amerson
:( we still need to fix thisPending

© 2022 - 2024 — McMap. All rights reserved.