SessionState lock problem

A

Alphapage

Hello,

Asp.net Ajax doc tells that the previous request is cancelled. But in my
example code, it doesn't seems to be.
When I click on Button1, the page sleeps during 20s and if I click quickly
on Button2, the response arrives (label2 is displayed) after 20s.
I know the problem is about SessionState which is in locked state.(ie if I
add EnableSessionState="False" to the @Page directive, label2 is updated
quickly).
How can I set Button1 to request EnableSessionState="False" and Button2 to
request EnableSessionState="True" ?
Have I to build a custom HttpHandler ?
If so, thanks in advance to tell me the way.


Here is my code:

<%@ Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs"
Inherits="WebApplication1.WebForm2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">

function pageLoad() {
}

</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button1"
onclick="Button1_Click" />
<asp:Button ID="Button2" runat="server"
onclick="Button2_Click"
Text="Button2" />
<asp:Label ID="Label1" runat="server"
Text="Label1"></asp:Label>
<asp:Label ID="Label2" runat="server"
Text="Label2"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace WebApplication1
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(20000);
Label1.Text = "end sleeping";
}

protected void Button2_Click(object sender, EventArgs e)
{
Label2.Text = "test updated:"+DateTime.Now.ToLongTimeString();
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top