2

When a client send a request to IIS, there is a connection between the client and the server. If client requests the a.aspx, the code in a.aspx as below.

 protected void Page_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 10; i++)
            {
                Thread.Sleep(1000);
                Response.Write(i+"<br>");
                Response.Flush();
            }
        }

So it means that the connection keeps alive for 10s. is it right?【question 1】

10 seconds later, the connection will be closed?【question 2】

if I edit the code with 'while(true)', as below:

while(true)
            {
                Thread.Sleep(1000);
                Response.Write(i+"<br>");
                Response.Flush();
            }

The connection is always alive?? or when will it be timeout?【question 3】

These are my questions.

roast_soul
  • 3,554
  • 7
  • 36
  • 73
  • You might find this interesting although it doesn't answer your question. There are also some "long polling" frameworks you could google up as well that might be of interest. http://encosia.com/easy-incremental-status-updates-for-long-requests/ – AaronLS Nov 16 '12 at 05:24
  • possible duplicate of [Relation between HTTP Keep Alive duration and TCP timeout duration](http://stackoverflow.com/questions/2735883/relation-between-http-keep-alive-duration-and-tcp-timeout-duration) – Liam Jan 06 '14 at 12:18

0 Answers0