asp.net page load twice problem

Tony Dong

Usenet Archive
Joined
Jun 2, 2005
Messages
3
Reaction score
0
Hi there

I have one application use C# for asp.net, when I debug and write code inside the page_load, it is loading twice, also I put IsNotPostBack, it still load two times, any one have the same problem, and how to solve it?

by the way, I am using asp.net 1.1 version.

Thanks

Tony
 

Yisheng

Usenet Archive
Joined
Jun 10, 2005
Messages
1
Reaction score
0
Tony, I had this problem today and spent quite a few hours on it. Finally I found out it was one of the <td> attributes that was causing the problem. The "background" attribute was assigned a color code, where it was probably expecting an image, a file, or something. Here is the partial code:

<TD valign="bottom" align="left" background="#B6C8DE">

bgColor, not background, should be assigned a color code. But when you cut and paste in a hurry in the Properties Window in the .net IDE, sometimes that happens. Your page may not have the same problem as mine, but it most likely involves an error condition, or a bad reference.

Yisheng
 

Andreas Bergmeier

Usenet Archive
Joined
Dec 4, 2003
Messages
7
Reaction score
0
Ashish said:
Really? It wud be interesting to know how is this affecting the postback ?
I encountered this, too (with having an empty background value). This seems to be a problem with alternative browsers only as it did show only in Firefox and Opera. To me it seems like the parser is skipping the page or something - and requesting it once again to be sure the data send was not skipped or so.

My 2c
Andreas
 
Joined
Jul 24, 2008
Messages
1
Reaction score
0
Hi guys (+/girls),

I too had this error, and after some hours of debugging I found out, it was because of an empty src-attribute in an image-tag, e.g.

<img src="" alt="" />


In the end of my pageload, I was setting this value dynamically via javascript, which is why I didn't figure it out at first. But I hereby confirm, that at least firefox will reload the page (silently, though) if this "error" is present. The problem wasn't there in IE7, and I haven't tested other browsers.

Hope this helps somebody.

Regards,
Frederik Schøning
 
Joined
Aug 7, 2008
Messages
1
Reaction score
0
Thank you Frederik, your solution solved the problem for me.

I had src="" in an IMG and also an IFrame, I don't know if the iframe also causes it. It was only affecting Firefox.

I would never have solved it without your help!
 
Joined
Aug 27, 2009
Messages
5
Reaction score
0
Use !IsPostBack event in page_load & write the code or call the function within that block like:

page_load()
{
if (!IsPostBack)
{
write the code;
}
}

I think its working

Bye
 
Joined
Sep 2, 2009
Messages
2
Reaction score
0
Firefox will fire Page_Load twice when Stylesheet path is empty or invalid

I faced the issue of Page_load hitting twice in FF (3.5) only.
There were no problems with the html tags/images etc. The page had a blank link to stylesheet
like

<LINK href="" rel="stylesheet">

This causes Firefox to reload the page, thinking it lost the css tag in an error.
As long as you dont have any post back specific processing, this can be annoying :)

Thanks guys! I learnt more about Firefox behaviour, and eventually solved a bug :)
 
Joined
Jun 14, 2010
Messages
1
Reaction score
0
PageLoad or postback fires twice

PageLoad or postback fires twice in IE
A project I just took over had the issue of several pages loading twice and after looking at it a while I found they were using the full path to the page for the URL attribute of response.redirect()

loading twic code example:
Response.Redirect("riptidehosting.com/blah/blah.aspx?SomeId=" & Session("SomeId") & "&k=2")
my code actually had the "http..." in there but I couldn't add it since I'm new to this group

Once I removed everything up to the page name it worked as expected.

Response.Redirect("blah.aspx?SomeId=" & Session("SomeId") & "&k=2")
**Updated here the ISSUE with HTTPS being called without the "s"
OK I know see why my page was really reloading. The site I'm working on is under https: and the url we were redirecting to was missing the "s" so when we loaded a non secure URL it was automatically being redirected to the page with https: but the query string was being dropped. By removing the incorrect complete URL I fixed the issue. Then I realized in a few cases for a redirect URL from another site we needed the full URL and without the "s" the page was reloading twice.


Hope it helps

Kinch
OnDemandProgramming
 
Last edited:
Joined
May 4, 2011
Messages
1
Reaction score
0
Page loading twice is ASP.NET

In my situation, this was being caused by the following:

1. AutoEventWireup = true in the .aspx page

<%@ Page Language="C#" ... AutoEventWireup="true" ... %>​

2. Web Form Designer generated code in the .aspx.cs code-behind page

#region Web Form Designer generated code

override protected void OnInit(EventArgs e) etc.....​

These conditions will cause the page to load twice.

To fix this, either set AutoEventWireup = false, or remove the Web Form Designer generated code from the code-behind .aspx.cs file.
 
Joined
May 4, 2011
Messages
4
Reaction score
0
wow..Thanks for informations because very helpfully. I'll try it....
grey.png
 
Joined
Sep 1, 2011
Messages
1
Reaction score
0
In my case, I was provided with a nice inline stylesheet with the following:

body {
[...]
background-image: url();
[...]
}

It appears that the empty url() generated a double load of my ASPX page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,245
Members
248,133
Latest member
DujonT

Latest Threads

Top