views:

94

answers:

2

The MSDN documentation for using an asynchronous controller mentions choosing an asynchronous controller when you want to provide a way for users to cancel requests.

I couldn't find any documentation related to actually allowing users to cancel asynchronous requests, however. Is there a way to indicate to ASP.Net and/or the MVC framework that a request should be canceled?

+1  A: 

The default timeout is 45 seconds, so if there is no response, it will be canceled by server. They did not allow users to cancel the request as to cancel one http request, you are creating another http request which is not a proper way.

Adeel
+1  A: 

If the asynchronous API that you called provides a way to cancel the request (either via .NET 4's CancellationToken class or via a CancelAsync method), you must call that to cancel whatever asynchronous operations are in flight. Otherwise, call AsyncManager.Finish (via the controller's AsyncManager property) to force the MVC framework to call your XxCompleted method immediately. Note that AsyncManager.Finish is really intended only if you need to bail out of requests that you have no other way of canceling (such as calling BeginXx / EndXx without a CancellationToken) and won't always work in other scenarios.

Levi
Thanks. That's what I was looking for.
Sean Carpenter