0

I have an asp.net webform that looks like:

public partial class Test : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Thread.Sleep(10000); // wait 10 seconds
        Response.Write("<h1>Hello world!</h1>");
    }
}

If two users make a request about the same time one user will have to wait 10 seconds and the other 20 right? I just opened my browser and made two requests to http://localhost:10144/test.aspx and one page opened in 10 seconds and the other in about 20. How can I have both users have to wait at most 10 seconds? Is it because the requests are coming from the same client?


Edit

Is because I am implementing polling in order for the server to send notifications to the client. Whenever I am polling the webserver if I am making another request to the website that request will take forever. Polling is so simple to implement I will later use something else such as websockets.

Solution

Thanks a lot for the help. Based on your comments what I will do is use a different cookie/session per request when polling. When polling I will use session A and wen making regular requests I will use session B. In other words I will have to cookieContainers when using: Using CookieContainer with WebClient class

Community
  • 1
  • 1
Tono Nam
  • 34,064
  • 78
  • 298
  • 470
  • 3
    No, not right. Each request is potentially handled on a different pooled worker thread. They won't interact how you think. But if the requests are from the *same user*, each will have the same session ID, and ASP.NET serializes access to Session for such requests. You can change that; don't remember where... – Andrew Barber Apr 29 '14 at 19:31
  • You can test the 'real' behavior by loading the pages concurrently on two different browsers, or one instance in incognito mode. – Andrew Barber Apr 29 '14 at 19:34
  • However why a customer need to be enabled to access 10 second after the first one??it a strange requirement..... – makemoney2010 Apr 29 '14 at 19:36
  • I am implementing polling. On a separate thread I make a request to the webserver every 20 seconds. Then I wait about 10 seconds on the server to reply back. If there is another request taking place then that request will have to wait for the polling request to finish. – Tono Nam Apr 29 '14 at 19:39
  • mmmmm curious i have to learn more about it never done before. – makemoney2010 Apr 29 '14 at 19:42

0 Answers0