How to send http request in asp.net without waiting for a response and without tying up resources

后端 未结 2 619
无人共我
无人共我 2020-12-29 12:36

In an ASP.Net application, I need to send some data (urlEncodedUserInput) via http POST to an external server in response to user input, without holding up the page response

2条回答
  •  时光说笑
    2020-12-29 13:16

    The only way I can think of that you would get a quick response from the other request is to have the page you're posting to open a thread using the ThreadPool.QueueUserWorkItem so that the main thread finishes the response before the time consuming work is complete. You should know that once the main thread exits you will not have access to the HttpContext which means no caching, server variables, etc... also shared drives will not work unless you Impersonate a user with permissions in the new thread. Threads are nice, but there are a lot of things to look out for.

提交回复
热议问题