In un controller asincrono in ASP.NET MVC, esiste un modo per indicare se/quando la richiesta viene interrotta dal client?Rileva una richiesta interrotta in ASP.NET MVC
[NoAsyncTimeout]
public void IndexAsync() {
var source = new CancellationTokenSource();
Task.Factory.StartNew(() => {
while (true) {
if (source.Token.IsCancellationRequested) {
AsyncManager.Finish();
return;
}
Response.Write(".");
Thread.Sleep(1000);
}
}, source.Token);
// Is there any way to do this?
Request.Aborted += (sender, e) => source.Cancel();
AsyncManager.OutstandingOperations.Increment();
}
possibile duplicato di [Rilevamento asincrona cliente disconnessione in ASP.NET MVC] (http://stackoverflow.com/questions/4772597/detecting-async-client-disconnect-in-asp- net-mvc) Ho appena trovato anche questo, risponde alla tua domanda anche con alcune altre informazioni. –