In ASP.Net MVC, the classic (synchronous) way to write an action method is to return ActionResult.  More recently, the ability to perform action methods asynchronously was added, by allowing action methods to return Task<ActionResult>.I have read https://msdn.microsoft.com/en-us/magazine/dn802603.aspx which explains that asynchronous action methods allow the web server thread to be returned to the thread pool while the action method is still running and allocated from the pool when method is ready to return the result.However, I don't understand how that works from a networking standpoint.  The web browser still has a connection open to the web server, so what happens to the server side of the connection while the thread that handled it is returned to the thread pool?
How do async action methods maintain their network connnection?
asp.net mvc;networking;async
A connection isn't much more than a record in a table.As long as both parties have a plan for routing packets from each other, the connection is open. It doesn't require either end to have a dedicated thread holding the connection open. It just requires that end party have sufficient information to route and process packets received from the other party.That said, there usually is a lot of complexity around handling connections, protecting them, and disposing of them gracefully. Protocols can include close/disconnect messages for Party A to inform Party B that I'm not listening to you anymore. Or conversely, a protocol could ask for Party A to occasional say I'm still here if it wants Party B to keep listening.But, even that stuff doesn't require a dedicated or per-connection thread. An open connection just requires that something on both ends of a connection is able to handle packets from each other.If you wanted to get really extreme, you could build an entire system that spun up and spun down a new threads for each packet. You could keep your open connections list in a text file. Hell, if you're designing the hardware, you could even turn off the main CPU and have the network card wake it up, perform a full boot, and then deliver the packet to the routine specified by your open connections table. And, it would probably be very very very slow; but, those very very very slow connections are still open connections.