question

HJKang-5938 avatar image
0 Votes"
HJKang-5938 asked RickPiovesan-5213 commented

asp.net webform page_load run twice

Hello.
I have been developing using ASP.NET program language for more than 10 years.
Today the project was so slow that I tried debugging.
Debugging results were very shocking.

I made an empty web project, and I made a webform.aspx
A code that creates a very simple method and executes it in Page_Load.

No events occur except one page call.
But Page_Load was executed twice.

As far as my knowledge is concerned, Page_Load will only be executed once upon loading the first page before the event is issued. This was the basis of ASP.NET C#.
Is my knowledge wrong?

Here the test() method runs twice.
Am I wrong?


 public partial class WebForm6 : System.Web.UI.Page
 {
     protected void Page_Load(object sender, EventArgs e)
     {
         test();  <-- calling twice
     }

     private void test() <-- calling twice
     {
         int a = 1;
         int b = 2;
         Response.Write(a * b);
     }
 }


2675-aspent-qa.png


partner-center-api
aspent-qa.png (103.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

som avatar image
0 Votes"
som answered

Page_Load event will fire only once. unless you do gain Post back again using some button click or ajax call. After adding if(!Page.IsPostBack) check did it fired only once. can you share the response also.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Jerryzy avatar image
0 Votes"
Jerryzy answered RickPiovesan-5213 commented

Hi HJKang,

Welcome to Q&A Forum.

This forum mainly discussed about Partner Center API related question, as this question is more related with .NET Web Development, I suggest you can create a new thread in ASP.NET Forum below:


ASP.NET Forums



Thanks

Best Regards

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

HJKang did you ever post onto ASP.NET forum as suggested? If so where? if not why not - did you resolve this? I have same issue (Sep 2020) and is major issue for existing website. I see followers - anyone else have comments? resolution? posted a bug report anywhere? Veru concerned,

0 Votes 0 ·