I'm doing some research on Cancelling Async Requests through WebAPI,
Recently I discovered that latest version of WebApi(not .NET-Core's), supports cancellation tokens. As a test I've written this code.
public async Task<string> VeryLongRequest(string Key, CancellationToken token)
for (int i = 0; i < 5; ++i)
if (false == token.IsCancellationRequested)
This code works, and the cancellation token is updated, when a user closes the window/refreshes/ or navigates to a new page (Not on an SPA).
Being that HTTP Request's are suppose to be stateless, How is the cancellation mapping back to the request?
And how can I Manually Invoke a cancellation from my client?