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.
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);
}
}
----------------------
2 answers
Sort by: Most helpful
-
-
Jerryzy 10,571 Reputation points
2020-02-10T07:50:48.85+00:00 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:
Thanks
Best Regards