Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top