SessionState lock problem

Discussion in 'ASP .Net' started by Alphapage, Mar 21, 2008.

  1. Alphapage

    Alphapage Guest

    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();
    }
    }
    }
    Alphapage, Mar 21, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Flemming Jensen
    Replies:
    0
    Views:
    341
    Flemming Jensen
    Aug 22, 2003
  2. Fuzzyman
    Replies:
    3
    Views:
    476
    Andrew MacIntyre
    Dec 5, 2003
  3. Robert Brewer
    Replies:
    0
    Views:
    478
    Robert Brewer
    Dec 5, 2003
  4. k3xji
    Replies:
    7
    Views:
    783
    Gabriel Genellina
    Dec 30, 2008
  5. nano2k

    Application.Lock()/UnLock() or lock(Application)

    nano2k, Jul 23, 2007, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    265
    nano2k
    Aug 9, 2007
Loading...

Share This Page