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.
Asked
Active
Viewed 1,441 times
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? – Tseng Jun 05 '18 at 14:51
-
I am aborting request from client using javascript or from WPF client calling Task.Cancel() and passing CancellationToken to service call – Samvel Siradeghyan Jun 05 '18 at 14:59
-
Did you try the above? This is the way is supposed to work. It's an cancellation token – Tseng Jun 05 '18 at 15:02
-
My issue is that HttpContext.RequestAborted.IsCancellationRequested is false, but action is aborted from client – Samvel Siradeghyan Jun 05 '18 at 15:06
-
2When I use Kestrel as server it is working, but when server is IIS it is not working – Samvel Siradeghyan Jun 05 '18 at 15:08
-
Did you try if its still an issue with ASP.NET Core 2.1 in process hosting? https://blogs.msdn.microsoft.com/webdev/2018/02/28/asp-net-core-2-1-0-preview1-improvements-to-iis-hosting/ – Tseng Jun 05 '18 at 17:20
-
I will try later – Samvel Siradeghyan Jun 05 '18 at 19:38
1 Answers
8
As I know this is known issue and doesn't fixed yet. See more details on ANCM project page.

Karen Tazayan
- 126
- 4
-
I was hoping this is fixed after 2 years :) Thanks for response. – Samvel Siradeghyan Jun 05 '18 at 15:35
-
-
1Same issue here: https://stackoverflow.com/questions/50110101/kestrel-iis-reverse-proxy-requestaborted-not-triggered . I asked the MS team about it as well...tumbleweeds. – mikeo Jun 05 '18 at 16:50
-