asp.net core - Custom AspCore Middleware with cancellation Token -


when have custom asp core middle ware want retrieve cancellation token request

i tried add signature of invoke this:

 public async task invoke(httpcontext context,cancellationtoken token) 

but son add it isn't called more.

what doing wrong?

i think idea not able cancel invocation of middleware, inside middleware if call async task accepts cancellation token can create 1 , pass in calling inside there.

a common scenario cancel task if request aborted, create token this:

cancellationtoken cancellationtoken => context?.requestaborted ?? cancellationtoken.none; 

and call async service getting data or querying db, if request aborted cancellation request should happen


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -