Home How are CancellationToken Transported on Web Requests
Reply: 0

How are CancellationToken Transported on Web Requests

user962 Published in March 20, 2018, 3:24 pm

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)

    return "Complete";

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?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.296048 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO