locked
Page events firing twice RRS feed

  • Question

  • User1821416443 posted

    We have a very large legacy 4.x (currently 4.7.2.) enterprise line of business web (VB) app. I've recently discovered that for many (most?all?) ASPX pages the page events run twice. This is same issue as reported here:
    https://docs.microsoft.com/en-us/answers/questions/8269/aspnet-webform-page-load-run-twice.html
    I don't know what happened to that person, if it got resolved or not.

    This is now crippling our business app. I can see it happening by putting breakpoint on any page, on any "Page_Load" method. Wits end here .. anyone else discover this? Any thoughts, clues, potions or antidotes appreciated.

    As the used car adverts say - "serious replies only" please. This is a web app that has been running flawlessly for over a decade. This was discovered whist it was 4.6.2, we upgraded to 4.7.2 on the desperate hope that would resolve all things .. was not to be.

    Panicking .. Rick.

    Wednesday, September 16, 2020 1:46 AM

Answers

  • User475983607 posted

    If you are sure is not AutoEventWireUp...

    We see this symptom with ASP.NET VB Web Forms when there are two handler assignments.  One in the markup and another in the code behind.

    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    
    End Sub

    Other causes we see are double clicks. 

    The double click causes two requests while the double handler assignment executes the handler twice in one request.  

    I recommend basic debugging to figure out if you are seeing double requests or the handler is executing twice in a single request.  That should direction on where to focus you're efforts.

    Other things that can cause double requests is JavaScript/AJAX.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 16, 2020 12:28 PM

All replies

  • User753101303 posted

    Hi,

    Likely a problem with AutoEventWeriteup: https://forums.asp.net/t/932513.aspx?What+is+AutoEventWireup+ Do you find this to be set to "false" in @Page?

    Wednesday, September 16, 2020 7:58 AM
  • User1821416443 posted

    As noted, this app has been running normally for a decade. So,no, AutoEvenWireup was not accidently set 'true' across several hundred pages; likely is not the problem.
    It looks more like, for at least the VB environment, that AutoEventWireup is being processed as 'true' regardless of its setting.

    Wednesday, September 16, 2020 11:24 AM
  • User475983607 posted

    If you are sure is not AutoEventWireUp...

    We see this symptom with ASP.NET VB Web Forms when there are two handler assignments.  One in the markup and another in the code behind.

    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    
    End Sub

    Other causes we see are double clicks. 

    The double click causes two requests while the double handler assignment executes the handler twice in one request.  

    I recommend basic debugging to figure out if you are seeing double requests or the handler is executing twice in a single request.  That should direction on where to focus you're efforts.

    Other things that can cause double requests is JavaScript/AJAX.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 16, 2020 12:28 PM
  • User1821416443 posted

    Hello and thanks for reply.
    Sheepish discovery - i just found leftover javascript code from some debugging session sometime in the past:  an ajax call in the base master page.,which apparently triggers a full refresh of the page - distressing to say the least!
    I marked prior as answer because of trailing remark re AJAX - which got me looking.  Thanks all!

            $.ajax({
                beforeSend: function () {
                    //##alert("base: ajax beforeSend")
                },
                complete: function () {
                    //##alert("base: ajax afterSend")
                }
            });

    Wednesday, September 16, 2020 1:11 PM