0

I understand that ASP.NET serves requests using worker threads. Therefore client A and client B can make requests and the requests are dealt with concurrently.

Can a client make multiple requests concurrently. Please see the code below:

Imports System.Threading
Partial Class Default5
    Inherits System.Web.UI.Page

    Dim intCount1 As Integer, intCount2 As Integer

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'If Session("Test") = "" Then
        Session("Test") = Request.QueryString("ID")
        'End If
        Response.Write(Session("Test"))
    End Sub
End Class

Imports System.Threading
Partial Class Default4
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("Test") <> "" Then
            For intCount1 = 0 To 10
                Response.Write(Session("Test") & "," & intCount1 & "<br>")
                Thread.Sleep(1000)
            Next
        End If
    End Sub
End Class

Please open Default5.aspx by specifiying this URL: default5.aspx?id=1 and open another page with this URL: default5.aspx?id=2. Then from the browser with default5.aspx?id=1 open navigate to default4.axpx (by specifying the URL) and whilst this is running, navigate to default4.axpx from the browser with default5.aspx?id=2 open. The result in both cases is:

2,0
2,1
2,2
2,3
2,4
2,5
2,6
2,7
2,8
2,9
2,10

The session variable is 2 in both cases (I understand why this is). Please see a question I asked yesterday: ASP.NET - Accessing web page twice from client. The session variable is not 2 in both cases in this example.

My question is; can ASP.NET process multiple requests from the same client at the same time. Wins response seems to suggest that one request is processed at a time.

2 Answers 2

1

For anyone else finding this post, if you don't need write access to Session, declaring readonly access allows ASP.NET to run requests concurrently because it doesn't have to obtain a session lock:

In pages:

EnableSessionState="ReadOnly"

Or in generic handlers by implementing:

IReadOnlySessionState
0
My question is; can ASP.NET process multiple requests 
from the same client at the same time.

Yes if you disable session, or use a handler with out session, or made a totally custom session of yours.

Its may also help if you use more than one pool for the same web applications making a "web garder"

You can also read:
ASP.NET Server does not process pages asynchronously
Trying to make Web Method Asynchronous
Web app blocked while processing another web app on sharing same session
What perfmon counters are useful for identifying ASP.NET bottlenecks?
Replacing ASP.Net's session entirely

8
  • What do you mean by: "if you disable session"? The example code I have provided in the question uses session variables. Thanks.
    – w0051977
    Oct 20, 2012 at 12:28
  • @w0051977 Yes I see the example that use session variables as a test, if you need them and you can not avoid them you can not with the existing session code from asp.net - so you need to make your custom session handle code (I have made one for that reason, is not so difficult)
    – Aristos
    Oct 20, 2012 at 12:31
  • @w0051977 The session is actually connect the cookie of the user with a line on a database that keep some data there.
    – Aristos
    Oct 20, 2012 at 12:32
  • What happens if you have web server A and web server B. The user can choose which web server to go to when using the application?
    – w0051977
    Oct 20, 2012 at 12:33
  • @w0051977 Its all about programming. If you programming it, user can do that. If you let the automatic existing procedure that select what server or what pool is going to be used, then you can not do that.
    – Aristos
    Oct 20, 2012 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.