ASP.NET does not allow concurrent requests for the same session; meaning that a user can only make 1 request at a time.
For example, say we have Test1.aspx
:
public partial class Test1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Session["test"] = 1;
System.Threading.Thread.Sleep(int.Parse(Request.QueryString["timeout"]));
}
}
... and Test2.aspx
:
public partial class Test2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Session["test"] = 1;
Label1.Text = DateTime.Now.ToString("dd/MM/yy HH:mm:ss");
}
}
When we visit Test1.aspx?timeout=10000
, and then immediately after visit Page2.aspx
, the 2nd request will have to wait for 10 seconds until the first request has finished.
I just learnt this today, and I've been using ASP.NET for 5 years! I didn't really believe it until I read it at the bottom of an MSDN page (ASP.NET Session State Overview).
So, is there a way to force concurrency? That is, other than making pages faster, or moving long running code to a background thread. I'm aware that you can make the session read only, but I'm not entirely sure this is a practical option.