0

Ok this is the weirdest thing I have seen in a while...

I am using VS studio 2010 to build a asp.net (framework 4.0) website. My code behind is in VB.Net, My testing browser is Firefox (latest version), also tested on IE8 and Google Chrome, same behavior.

Basically I have a LinkButton in a DataRepeater in a UpdatePanel. The _ItemCommand event DOES FIRE for as long as I use the page regularly (every few minutes or so).

The problem is this: When I open another webpage (in another browser tab) and sit on it for like 1 hour or so and then come back to test page in the browser tab and click on the LinkButton, no event is fired and the page gets a reload. Like if the button had just died on me.

I first tough it might be a Session TimeOut issue but I logged the SessionID in a text file and the Session DOES NOT expire. <<<< Using new method for detecting TimeOut

I can confirm (logfiles) that the root of my problem is that the _ItemCommand event simply stops firing. I just have no idea why it does.

I have tried most solutions proposed under similar problems (event not firing) but my problem is positively different because my event DOES fire... Only for a limited time.

My Repeater ViewState is enabled. I have tried changing the LinkButton for a Button but no joy same problem. I have tried the uping the AsyncPostBackTimeout of the ScryptManager... no joy either. I have tried sessionState mode="StateServer". I have tried disabling my AVG Link Scanner.

So PLEASE, any idea... Don't be shy, at this point I'm ready to consider anything.


Here is the code I'm now using to check for Session Timeout:

If Context.Session IsNot Nothing And Context.Session.IsNewSession _
    And Page.Request.Headers("Cookie") IsNot Nothing _
    And Page.Request.Headers("Cookie").IndexOf("ASP.NET_SessionId") >= 0 Then

    'SESSION HAS TIMEDOUT
End If

HERE IS THE PAGE MARKUP

<asp:UpdatePanel ID="udpRSSFeeds" runat="server" UpdateMode="Conditional">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="cmdSearch" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="drpNewsFeed" EventName="ItemCommand" />
        <asp:AsyncPostBackTrigger ControlID="cmdViewAll" EventName="Click" />
    </Triggers>
    <ContentTemplate>

        <table class="Borderless" cellpadding="0" cellspacing="0"  style="width:100%">
        <tr><td class="lblHeaderText">NEWS FEEDS</td></tr>

        <%--BEGIN: SEARCH GIZMO--%>
        <tr><td>
            <table class="Borderless" style="width:100%;" cellpadding="0" cellspacing="0">
                <tr>
                    <td style="text-align:right; vertical-align:middle; height:32px;" >
                        <asp:TextBox ID="tbxSearchBox" runat="server" MaxLength="50" AutoCompleteType="None" Font-Size="16px" style="height:20px; width:187px; font-size:16px; border-style:solid; border-color:#54d242;" onfocus="Javascript:this.focus();this.select();" ></asp:TextBox>
                    </td>
                    <td style="text-align:left; vertical-align:middle; width:150px; height:32px;" >
                        <asp:ImageButton ID="cmdSearch" ImageUrl="~/GUIImages/cmdSearch.jpg" ToolTip="Search feed(s) for keyword(s)." Height="26px" Width="26px" runat="server" BorderStyle="None" ImageAlign="Middle" />
                    </td>
                </tr>
            </table>
        </td></tr>
        <%--END: SEARCH GIZMO--%>

        <%--BEGIN FEED LIST--%>
        <tr><td style="padding:3px 0px 3px 0px;"><asp:LinkButton ID="cmdViewAll" runat="server" CssClass="MenuItemActive" PostBackUrl="" CausesValidation="false" Text="* View ALL RSS Feeds"></asp:LinkButton></td></tr>                        
        <asp:XmlDataSource ID="xdsNewsFeed" runat="server" DataFile="App_Data/RSSFeeds.xml" XPath="dataroot/qryRSSFeed"></asp:XmlDataSource>
        <asp:Repeater ID="drpNewsFeed" runat="server" DataSourceID="xdsNewsFeed" EnableViewState="true" >
            <ItemTemplate>
                <tr><td style="padding:3px 0px 3px 0px;">
                    <asp:LinkButton ID="cmdSelectNewsFeed" runat="server" CssClass="MenuItem" CausesValidation="false" CommandName='<%#XPath("ID")%>'>- <%#XPath("Title")%></asp:LinkButton>
                </td></tr>
            </ItemTemplate>
        </asp:Repeater>
        <%--END FEED LIST--%>

        <tr><td>&nbsp;</td></tr>
        </table>

    </ContentTemplate>
</asp:UpdatePanel>

HERE IS THE PAGE CODE BEHIND

Protected Sub drpNewsFeed_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles drpNewsFeed.ItemCommand
    Dim oLogger As New nebLogManager("TESTNWOSGN.txt")

    oLogger.TraceStart("drpNewsFeed_ItemCommand (" & Session.SessionID & ")")

    'some code that never gets run because the event is not fired...

    oLogger.TraceStop("drpNewsFeed_ItemCommand (" & Session.SessionID & ")")
End Sub


Protected Sub cmdSearch_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles cmdSearch.Click
    Dim oLogger As New nebLogManager("TESTNWOSGN.txt")


    oLogger.TraceStart("cmdSearch_Click (" & Session.SessionID & ")")

    'some code that never gets run because the event is not fired...

    oLogger.TraceStop("cmdSearch_Click (" & Session.SessionID & ")")
End Sub

Not sure if its important but it uses a master_page on which sits the ScriptManager


COMPREHENSIVE TEST SCENARIO:

  1. BROWSE TO: http://www.nwosurvivalguide.com/NWOSGN.aspx
  2. CLICK on a News Feed (left side)
  3. LET sit for 30ish minutes
  4. GO BACK and click on another news feed

Result >>> Event not fired but page loads Page_Init detects a Session Timeout. If you refresh the page everything become functional again.

  • "I logged the SessionID in a text file" - how does this ensure the session hasn't timed out? The default timeout is 20 minutes I think, so if you waited an hour and your text file says the session didn't time out, and you haven't altered the timeout in the web.config, then I think you're logging isn't doing what you think it's doing. – jhsowter Feb 08 '12 at 05:34
  • The session ID is stored in a cookie, and the cookie's aspnet_sessionId value is reused for subsequent sessions even if they have timed out on the server side. – jhsowter Feb 08 '12 at 05:36
  • Humm I see... I was under the impression that every new session would get a new SessionID... Thats how it behaved locally... I tried augmenting session timeout to 120 minutes... still no joy. I know that even tho I set my session timeout to 120, certain severs settings may override this... Any one has a good idea to help me check if the session expires? – user1196190 Feb 08 '12 at 17:21
  • jhshowter, thanks for that tip BTW. Do you believe that a Session Timeout could cause that kind of "dead button" behavior? – user1196190 Feb 08 '12 at 17:28
  • Post your code with page markup and the ItemCommand event. If you want to know when your sessions are timing out, log it in the [Session_End event](http://www.techrepublic.com/article/working-with-the-aspnet-globalasax-file/5771721) in the Global.asax file. It could be something to do with the session, but it would depend on what your code does. – jhsowter Feb 08 '12 at 22:36
  • Thank again jhsowter for your quick reply. I will log traces on Session_End event so we know if the session is involved. Ounce I got that figured out I will report back and post the markup code and code behind. – user1196190 Feb 09 '12 at 17:22
  • Ok, no luck with the Session_End event. It simply never fires. I did read on some board that it was unreliable at best... anyway What I could see is that I get ANOTHER Session_Start event with the same SessionID when my page reloads after the bug. I also tested the session timeout using a snippet of code (pasted it in my main post) I found on the boards that seem to suggest my session is timing out. – user1196190 Feb 09 '12 at 23:47
  • I also noticed that cmdSearch also stop firing its event. This button is NOT withing the Repeater that's why I mention it. – user1196190 Feb 10 '12 at 00:20
  • To recap, you may test the scenario here: http://www.nwosurvivalguide.com/NWOSGN.aspx – user1196190 Feb 10 '12 at 00:21
  • I'm currently testing if the problem will occur if I stay idle on the test page without moving to another browser tab. I'l report my findings in a few. – user1196190 Feb 10 '12 at 00:27
  • Ok no need to open another browser tab to reproduce the problem. I will post a comprehensive test scenario at the end of my main post. – user1196190 Feb 10 '12 at 00:43
  • I'm going to contact my hoster's support and see if they have that Session Timeout on lock-down. Ask them if they can up it... I will post my results as I get them – user1196190 Feb 10 '12 at 01:10
  • Using Chrome, I didn't get the behaviour you describe when I followed the test scenario. – jhsowter Feb 10 '12 at 03:04
  • I've been uploading another version with Session State mode = Server State instead of InProc (default). It was a suggestion I found on my hoster's forum. It may have fixed the issue... Not sure will report. And Thanks a lot for that Chrome test I will check it out. – user1196190 Feb 10 '12 at 03:11
  • DID NOT fix my problem. – user1196190 Feb 10 '12 at 16:30
  • Tried the test scenario with Google Chrome... Same results. – user1196190 Feb 10 '12 at 16:32
  • Ok, first: Session_END DOES fire. It was my logger that was using HttpContext to grab the file path but its not available in SessionEnd event. So YES my session times out. And I finally got a response from my hoster. Will post the details in the answer. – user1196190 Feb 15 '12 at 16:11

2 Answers2

1

First I wish to thank JHSOWTER for pointing out that my initial session timeout detection logic was flawed. That really sent me back on the right track.

So the problem was that my session was timing out due to application pool recycling.

The standard SessionTimeout solution would not work because I am on a shared hoster who controls the application pool timeout.

The SOLUTION was to add the following lines to the Web.Config file (within the <system.web> tag):

<sessionState timeout="60" cookieless="false" mode="StateServer" />
<machineKey ... />

To generate my machine key tag I used this tool: http://aspnetresources.com/tools/machineKey

After those changes all my problems went away.

Again thanks a lot for the help.

0

I have googled around for this and found a fair few people are having similar behaviour because of the AVG Link Scanner.

Firefox __doPostBack not working after idle time

http://forums.asp.net/post/4021595.aspx

Community
  • 1
  • 1
jhsowter
  • 619
  • 3
  • 8