Arturo León
Arturo León

Reputation: 449

If a user aborts the connection, does the code keep running?

I have an endpoint on my project that takes long time to load (+2 seconds). If the user aborts the connection, does all the instructions keep running?

I seen that not all the steps on the method are completed without throwing any error. My guess is that the connection is being aborted and the code execution stops at that time.

If that is the case, using AsyncController will solve the issue?

I'm using .NET MVC 5 with IIS 7.

Upvotes: 1

Views: 28

Answers (1)

robrich
robrich

Reputation: 13205

As soon as IIS notices the user aborted, then ASP.NET throws a ThreadAbortException. Technically, you shouldn't block it, though sometimes careful handling of the exception can get your work done.

If this happens frequently, write the details to a queue and in a windows service dequeue the message and complete the task. If you're in Azure, you can use Azure Queues and a Web Job to do this really, really easily.

Upvotes: 2

Related Questions