Why does ASP.NET terminate asynchronous requests?

I know this is not the right way to write code, but I still like to understand this behavior - whenever I execute an async HTTP request without waiting for the result, does it look like the request is complete? (I do not see this on the violinist).

Code example:

public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("http://localhost.fiddlerhttpclient/");
                    var response = client.GetAsync("zzzz");
                }
            }
        }
    }

If I changed the code to:

var response = client.GetAsync("zzzz").Result;

I see it on the violinist. I don’t understand why - I would expect the request to continue processing in the background anyway, so why is it not?

+4
source share
1 answer

HttpClient , . (- using) GetAsync, , HTTP-, .

+4

Source: https://habr.com/ru/post/1688853/


All Articles