Cancel HttpClient does not inform the server of cancellation

I am trying to create a client for the OWIN web service that informs the service if the request is canceled, so the service can cancel the current ongoing operation for this request.

On the server side, I have an ApiController with this method:

[HttpGet]
[Route("Get")]
public int Get(CancellationToken ct)
{
  Console.WriteLine("started!");

  while (!ct.IsCancellationRequested)
  {
    Thread.Sleep(500);
  }

  Console.WriteLine("canceled!");

  return 0;
}

API Edge, ( "!", , , ), , ( Chrome, Postman, HttpClient, HttpWebRequest), CancellationToken . Edge , , , HttpClient? GetAsync() CancellationToken , Dispose() CancelPendingRequests() HttpClient, .

+4
1

Nuget

Microsoft.Owin
Microsoft.Owin.Host.HttpListener
Microsoft.Owin.Hosting
Microsoft.Owin.SelfHost

to v3.1.0, , , Edge, Chrome HttpClient. 2.0, , . , Edge . ,

+1

Source: https://habr.com/ru/post/1688118/


All Articles