asp.net page load twice problem

Discussion in 'ASP .Net' started by Tony Dong, Jun 2, 2005.

  1. Tony Dong

    Tony Dong Guest

    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
    Tony Dong, Jun 2, 2005
    #1
    1. Advertising

  2. Tony Dong

    Yisheng Guest

    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

    Tony Dong wrote:
    > 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, Jun 10, 2005
    #2
    1. Advertising

  3. Tony Dong

    Ashish Guest

    Really? It wud be interesting to know how is this affecting the postback ?


    --
    Thanks and Regards,
    Ashish Gupta




    "Yisheng" <> wrote in message
    news:...
    > 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
    >
    > Tony Dong wrote:
    > > 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

    >
    Ashish, Jun 21, 2005
    #3
  4. Ashish wrote:
    > Really? It wud be interesting to know how is this affecting the postback ?
    >
    >
    > --
    > Thanks and Regards,
    > Ashish Gupta

    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
    Andreas Bergmeier, Aug 1, 2005
    #4
  5. Tony Dong

    Madbyggeren

    Joined:
    Jul 24, 2008
    Messages:
    1
    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
    Madbyggeren, Jul 24, 2008
    #5
  6. Tony Dong

    RobertJohnson

    Joined:
    Aug 7, 2008
    Messages:
    1
    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!
    RobertJohnson, Aug 7, 2008
    #6
  7. Tony Dong

    hellobiswa2001

    Joined:
    Aug 27, 2009
    Messages:
    5
    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
    hellobiswa2001, Aug 27, 2009
    #7
  8. Tony Dong

    nkindia

    Joined:
    Sep 2, 2009
    Messages:
    2
    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 :)
    nkindia, Sep 2, 2009
    #8
  9. Tony Dong

    kreindl

    Joined:
    Jun 15, 2010
    Messages:
    1
    Location:
    Denver
    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: Jun 22, 2010
    kreindl, Jun 15, 2010
    #9
  10. Tony Dong

    jiykoth

    Joined:
    May 4, 2011
    Messages:
    1
    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.
    jiykoth, May 4, 2011
    #10
  11. Tony Dong

    vongeuca

    Joined:
    May 4, 2011
    Messages:
    4
    Location:
    california
    wow..Thanks for informations because very helpfully. I'll try it....
    [​IMG]
    vongeuca, May 4, 2011
    #11
  12. Tony Dong

    BillFR

    Joined:
    Sep 1, 2011
    Messages:
    1
    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.
    BillFR, Sep 1, 2011
    #12
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bob Barrows

    Re: Page Load Event Fires Twice

    Bob Barrows, Jul 9, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    385
    Bob Barrows
    Jul 9, 2003
  2. Krzysztof Rozmus

    All pages in ASP.NET application load twice

    Krzysztof Rozmus, Jul 23, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    354
    Krzysztof Rozmus
    Jul 25, 2003
  3. Samy
    Replies:
    2
    Views:
    1,337
  4. Kiuhnm

    twice(twice(x))

    Kiuhnm, Apr 1, 2006, in forum: C++
    Replies:
    2
    Views:
    386
    Kiuhnm
    Apr 1, 2006
  5. DBLWizard

    ASP Image causes page to load twice

    DBLWizard, Sep 6, 2007, in forum: ASP .Net
    Replies:
    9
    Views:
    1,382
    shailesh patel
    Apr 2, 2010
Loading...

Share This Page