Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP Image causes page to load twice

Reply
Thread Tools

ASP Image causes page to load twice

 
 
DBLWizard
Guest
Posts: n/a
 
      09-06-2007
Howdy All,

I need some help I can't believe this is bug in Visual Studio 2005 and
hasn't been reported yet, but I have recreated it on two different
machines with the same result. I created a brand new website using VS
2005 and the default.aspx page looks like this:

<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="Pgi.Hub.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Image ID="imgTest" runat="server" />
<asp:Label ID="Label1" runat="server" Text="PageCount:"/>
<asp:Label ID="Label2" runat="server" />
</div>
</form>
</body>
</html>

And the Default.aspx.cs page looks like this:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

if (Session["Default"] == null)
{
Session["Default"] = 0;
}

Session["Default"] = (int)Session["Default"] + 1;
Label2.Text = Session["Default"].ToString();
}
}

The first time the page loads it displays PageCount:1 if you hit
refresh again it shows PageCount:3. If you put a break point in the
Page_Load it will hit the break point twice each time you load the
page. This seems to be tied to the Image control, because you can
remove the <ASP:Image ...> entry from the page and it only loads
once. Also it seems to be a ghost page because the the second time
through the Label2.Text is set to 2 but the page that displays only
says 1.

I would appreciate any feedback or thoughts on what I'm doing wrong or
if there is some way around this and the best way to report it to
Microsoft if I'm not wrong.

Thanks

dbl

 
Reply With Quote
 
 
 
 
George Ter-Saakov
Guest
Posts: n/a
 
      09-06-2007
Your code works fine on my machine. IE 7.
What browser are you using?
I suspect the problem is that you have Image control and no source fro image
(src) assigned.
So the generated HTML <img src=""> might trigger the request for the same
page.
Since browser trying to concatenate the src path with the path of the page
and I am not sure what is the rule when src is blank.

George.



"DBLWizard" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Howdy All,
>
> I need some help I can't believe this is bug in Visual Studio 2005 and
> hasn't been reported yet, but I have recreated it on two different
> machines with the same result. I created a brand new website using VS
> 2005 and the default.aspx page looks like this:
>
> <%@ Page Language="C#" AutoEventWireup="true"
> CodeBehind="WebForm1.aspx.cs" Inherits="Pgi.Hub.WebForm1" %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitled Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <asp:Image ID="imgTest" runat="server" />
> <asp:Label ID="Label1" runat="server" Text="PageCount:"/>
> <asp:Label ID="Label2" runat="server" />
> </div>
> </form>


> </html>
>
> And the Default.aspx.cs page looks like this:
>
> using System;
> using System.Data;
> using System.Configuration;
> using System.Web;
> using System.Web.Security;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.WebControls.WebParts;
> using System.Web.UI.HtmlControls;
>
> public partial class _Default : System.Web.UI.Page
> {
> protected void Page_Load(object sender, EventArgs e)
> {
>
> if (Session["Default"] == null)
> {
> Session["Default"] = 0;
> }
>
> Session["Default"] = (int)Session["Default"] + 1;
> Label2.Text = Session["Default"].ToString();
> }
> }
>
> The first time the page loads it displays PageCount:1 if you hit
> refresh again it shows PageCount:3. If you put a break point in the
> Page_Load it will hit the break point twice each time you load the
> page. This seems to be tied to the Image control, because you can
> remove the <ASP:Image ...> entry from the page and it only loads
> once. Also it seems to be a ghost page because the the second time
> through the Label2.Text is set to 2 but the page that displays only
> says 1.
>
> I would appreciate any feedback or thoughts on what I'm doing wrong or
> if there is some way around this and the best way to report it to
> Microsoft if I'm not wrong.
>
> Thanks
>
> dbl
>



 
Reply With Quote
 
 
 
 
Lit
Guest
Posts: n/a
 
      09-06-2007
Your code works fine on my machine.
when I refresh the count goes, 1, 2, 3.....
No loading twice.

create a new page and see may be you have some double subscription to your
events.
what happens if AutoEventWireup="true" is false?

Lit


"DBLWizard" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Howdy All,
>
> I need some help I can't believe this is bug in Visual Studio 2005 and
> hasn't been reported yet, but I have recreated it on two different
> machines with the same result. I created a brand new website using VS
> 2005 and the default.aspx page looks like this:
>
> <%@ Page Language="C#" AutoEventWireup="true"
> CodeBehind="WebForm1.aspx.cs" Inherits="Pgi.Hub.WebForm1" %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitled Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <asp:Image ID="imgTest" runat="server" />
> <asp:Label ID="Label1" runat="server" Text="PageCount:"/>
> <asp:Label ID="Label2" runat="server" />
> </div>
> </form>
> </body>
> </html>
>
> And the Default.aspx.cs page looks like this:
>
> using System;
> using System.Data;
> using System.Configuration;
> using System.Web;
> using System.Web.Security;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.WebControls.WebParts;
> using System.Web.UI.HtmlControls;
>
> public partial class _Default : System.Web.UI.Page
> {
> protected void Page_Load(object sender, EventArgs e)
> {
>
> if (Session["Default"] == null)
> {
> Session["Default"] = 0;
> }
>
> Session["Default"] = (int)Session["Default"] + 1;
> Label2.Text = Session["Default"].ToString();
> }
> }
>
> The first time the page loads it displays PageCount:1 if you hit
> refresh again it shows PageCount:3. If you put a break point in the
> Page_Load it will hit the break point twice each time you load the
> page. This seems to be tied to the Image control, because you can
> remove the <ASP:Image ...> entry from the page and it only loads
> once. Also it seems to be a ghost page because the the second time
> through the Label2.Text is set to 2 but the page that displays only
> says 1.
>
> I would appreciate any feedback or thoughts on what I'm doing wrong or
> if there is some way around this and the best way to report it to
> Microsoft if I'm not wrong.
>
> Thanks
>
> dbl
>



 
Reply With Quote
 
DBLWizard
Guest
Posts: n/a
 
      09-06-2007
I question if "my" code works fine on your system. If you are saying
that you added a ImageUrl property to the Image and then the problem
went away then I can buy that. But I don't think my code as I entered
it above works perfectly on your system unless its something that
Microsoft did differently in IE 7. I am running both IE 6 and Firefox
2.0.0.6 and they both exhibit the behavior.

I just added the ImageUrl property and an image and the problem went
away. It even goes away if you have something in the
ImageUrl(ImageUrl="abcdefg") but it doesn't resolve properly. But if
the is blank ImageUrl="" or the tag is not there the problem does
exist.

I also reduced my page down to:

<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<img id="Image2" src="" alt=""/>
</div>
</form>
</body>
</html>

And it double loads so its not a Visual Studio bug but it is a bizarre
behavior. So thanks for pointing me in the correct direction.

dbl

On Sep 6, 11:45 am, "George Ter-Saakov" <(E-Mail Removed)> wrote:
> Your code works fine on my machine. IE 7.
> What browser are you using?
> I suspect the problem is that you have Image control and no source fro image
> (src) assigned.
> So the generated HTML <img src=""> might trigger the request for the same
> page.
> Since browser trying to concatenate the src path with the path of the page
> and I am not sure what is the rule when src is blank.
>
> George.
>
> "DBLWizard" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed) ups.com...
>
> > Howdy All,

>
> > I need some help I can't believe this is bug in Visual Studio 2005 and
> > hasn't been reported yet, but I have recreated it on two different
> > machines with the same result. I created a brand new website using VS
> > 2005 and the default.aspx page looks like this:

>
> > <%@ Page Language="C#" AutoEventWireup="true"
> > CodeBehind="WebForm1.aspx.cs" Inherits="Pgi.Hub.WebForm1" %>

>
> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
> >www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

>
> > <html xmlns="http://www.w3.org/1999/xhtml" >
> > <head runat="server">
> > <title>Untitled Page</title>
> > </head>
> > <body>
> > <form id="form1" runat="server">
> > <div>
> > <asp:Image ID="imgTest" runat="server" />
> > <asp:Label ID="Label1" runat="server" Text="PageCount:"/>
> > <asp:Label ID="Label2" runat="server" />
> > </div>
> > </form>
> > </html>

>
> > And the Default.aspx.cs page looks like this:

>
> > using System;
> > using System.Data;
> > using System.Configuration;
> > using System.Web;
> > using System.Web.Security;
> > using System.Web.UI;
> > using System.Web.UI.WebControls;
> > using System.Web.UI.WebControls.WebParts;
> > using System.Web.UI.HtmlControls;

>
> > public partial class _Default : System.Web.UI.Page
> > {
> > protected void Page_Load(object sender, EventArgs e)
> > {

>
> > if (Session["Default"] == null)
> > {
> > Session["Default"] = 0;
> > }

>
> > Session["Default"] = (int)Session["Default"] + 1;
> > Label2.Text = Session["Default"].ToString();
> > }
> > }

>
> > The first time the page loads it displays PageCount:1 if you hit
> > refresh again it shows PageCount:3. If you put a break point in the
> > Page_Load it will hit the break point twice each time you load the
> > page. This seems to be tied to the Image control, because you can
> > remove the <ASP:Image ...> entry from the page and it only loads
> > once. Also it seems to be a ghost page because the the second time
> > through the Label2.Text is set to 2 but the page that displays only
> > says 1.

>
> > I would appreciate any feedback or thoughts on what I'm doing wrong or
> > if there is some way around this and the best way to report it to
> > Microsoft if I'm not wrong.

>
> > Thanks

>
> > dbl



 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      09-06-2007
"Lit" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...

> Your code works fine on my machine.


And on mine.

> when I refresh the count goes, 1, 2, 3.....
> No loading twice.


Same here.


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
George Ter-Saakov
Guest
Posts: n/a
 
      09-06-2007
Well, you got your answer. It's a browser problem
Browser IE 6 and Firefox does not know what to do with html like
<img src="">
they are "concatenating" empty string with the page's url and comes up with
the same URL. And sends "GET" request for that image.

But I am surprised in that behavior as well.

George.



"DBLWizard" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
>I question if "my" code works fine on your system. If you are saying
> that you added a ImageUrl property to the Image and then the problem
> went away then I can buy that. But I don't think my code as I entered
> it above works perfectly on your system unless its something that
> Microsoft did differently in IE 7. I am running both IE 6 and Firefox
> 2.0.0.6 and they both exhibit the behavior.
>
> I just added the ImageUrl property and an image and the problem went
> away. It even goes away if you have something in the
> ImageUrl(ImageUrl="abcdefg") but it doesn't resolve properly. But if
> the is blank ImageUrl="" or the tag is not there the problem does
> exist.
>
> I also reduced my page down to:
>
> <%@ Page Language="C#" AutoEventWireup="true"
> CodeFile="Default.aspx.cs" Inherits="_Default" %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitled Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <img id="Image2" src="" alt=""/>
> </div>
> </form>
> </body>
> </html>
>
> And it double loads so its not a Visual Studio bug but it is a bizarre
> behavior. So thanks for pointing me in the correct direction.
>
> dbl
>
> On Sep 6, 11:45 am, "George Ter-Saakov" <(E-Mail Removed)> wrote:
>> Your code works fine on my machine. IE 7.
>> What browser are you using?
>> I suspect the problem is that you have Image control and no source fro
>> image
>> (src) assigned.
>> So the generated HTML <img src=""> might trigger the request for the same
>> page.
>> Since browser trying to concatenate the src path with the path of the
>> page
>> and I am not sure what is the rule when src is blank.
>>
>> George.
>>
>> "DBLWizard" <(E-Mail Removed)> wrote in message
>>
>> news:(E-Mail Removed) ups.com...
>>
>> > Howdy All,

>>
>> > I need some help I can't believe this is bug in Visual Studio 2005 and
>> > hasn't been reported yet, but I have recreated it on two different
>> > machines with the same result. I created a brand new website using VS
>> > 2005 and the default.aspx page looks like this:

>>
>> > <%@ Page Language="C#" AutoEventWireup="true"
>> > CodeBehind="WebForm1.aspx.cs" Inherits="Pgi.Hub.WebForm1" %>

>>
>> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
>> >www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

>>
>> > <html xmlns="http://www.w3.org/1999/xhtml" >
>> > <head runat="server">
>> > <title>Untitled Page</title>
>> > </head>
>> > <body>
>> > <form id="form1" runat="server">
>> > <div>
>> > <asp:Image ID="imgTest" runat="server" />
>> > <asp:Label ID="Label1" runat="server" Text="PageCount:"/>
>> > <asp:Label ID="Label2" runat="server" />
>> > </div>
>> > </form>
>> > </html>

>>
>> > And the Default.aspx.cs page looks like this:

>>
>> > using System;
>> > using System.Data;
>> > using System.Configuration;
>> > using System.Web;
>> > using System.Web.Security;
>> > using System.Web.UI;
>> > using System.Web.UI.WebControls;
>> > using System.Web.UI.WebControls.WebParts;
>> > using System.Web.UI.HtmlControls;

>>
>> > public partial class _Default : System.Web.UI.Page
>> > {
>> > protected void Page_Load(object sender, EventArgs e)
>> > {

>>
>> > if (Session["Default"] == null)
>> > {
>> > Session["Default"] = 0;
>> > }

>>
>> > Session["Default"] = (int)Session["Default"] + 1;
>> > Label2.Text = Session["Default"].ToString();
>> > }
>> > }

>>
>> > The first time the page loads it displays PageCount:1 if you hit
>> > refresh again it shows PageCount:3. If you put a break point in the
>> > Page_Load it will hit the break point twice each time you load the
>> > page. This seems to be tied to the Image control, because you can
>> > remove the <ASP:Image ...> entry from the page and it only loads
>> > once. Also it seems to be a ghost page because the the second time
>> > through the Label2.Text is set to 2 but the page that displays only
>> > says 1.

>>
>> > I would appreciate any feedback or thoughts on what I'm doing wrong or
>> > if there is some way around this and the best way to report it to
>> > Microsoft if I'm not wrong.

>>
>> > Thanks

>>
>> > dbl

>
>



 
Reply With Quote
 
DBLWizard
Guest
Posts: n/a
 
      09-06-2007
For everybody that this works fine with are ya'll using IE 7?

And I have decided that it still is a Visual Studio bug becuase if I
turn AutoEventsWireup to false the problem doesn't happen. Yes I know
that none of the events fire but still it is a bug in the event
handlers somewhere in Visual Studio. I don't have time at the moment
to dig into that and see exactly where the problem is as I have
already wasted a day trying to figure out what was causing this in the
first place ... but when I do I will try and add more details to this
post.

Thanks

dbl

On Sep 6, 12:37 pm, "Mark Rae [MVP]" <(E-Mail Removed)> wrote:
> "Lit" <(E-Mail Removed)> wrote in message
>
> news:%(E-Mail Removed)...
>
> > Your code works fine on my machine.

>
> And on mine.
>
> > when I refresh the count goes, 1, 2, 3.....
> > No loading twice.

>
> Same here.
>
> --
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net



 
Reply With Quote
 
Lit
Guest
Posts: n/a
 
      09-06-2007
I have IE 7 here. thanks for testing AutoEventsWireup.

Lit


"DBLWizard" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.com...
> For everybody that this works fine with are ya'll using IE 7?
>
> And I have decided that it still is a Visual Studio bug becuase if I
> turn AutoEventsWireup to false the problem doesn't happen. Yes I know
> that none of the events fire but still it is a bug in the event
> handlers somewhere in Visual Studio. I don't have time at the moment
> to dig into that and see exactly where the problem is as I have
> already wasted a day trying to figure out what was causing this in the
> first place ... but when I do I will try and add more details to this
> post.
>
> Thanks
>
> dbl
>
> On Sep 6, 12:37 pm, "Mark Rae [MVP]" <(E-Mail Removed)> wrote:
>> "Lit" <(E-Mail Removed)> wrote in message
>>
>> news:%(E-Mail Removed)...
>>
>> > Your code works fine on my machine.

>>
>> And on mine.
>>
>> > when I refresh the count goes, 1, 2, 3.....
>> > No loading twice.

>>
>> Same here.
>>
>> --
>> Mark Rae
>> ASP.NET MVPhttp://www.markrae.net

>
>



 
Reply With Quote
 
George Ter-Saakov
Guest
Posts: n/a
 
      09-06-2007
I failed to understand reasoning why it's Visual Studio bug.....

If the AutoEventsWireup is false then Page_Load is not wired as an even
handler. Your page is still called twice.
Replace
protected void Page_Load(object sender, EventArgs e)

with

protected override void OnLoad(EventArgs e)

and you will see that. Even with AutoEventsWireup = false.

------------------------------

You just learned today (and we did too)

that having <img src=""> on a page.aspx is the same as having <img
src="page.aspx">

That is all.

I would call it a browser's bug at most. But even that would be a stretch,
cause I am positive that behavior when src is empty is not determined in the
standard (never read it . But it's first time i come accross when someone
has empty src for image. If you need to make an invisible image just put
transparent gif 1x1 in there.



George.



"DBLWizard" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.com...
> For everybody that this works fine with are ya'll using IE 7?
>
> And I have decided that it still is a Visual Studio bug becuase if I
> turn AutoEventsWireup to false the problem doesn't happen. Yes I know
> that none of the events fire but still it is a bug in the event
> handlers somewhere in Visual Studio. I don't have time at the moment
> to dig into that and see exactly where the problem is as I have
> already wasted a day trying to figure out what was causing this in the
> first place ... but when I do I will try and add more details to this
> post.
>
> Thanks
>
> dbl
>
> On Sep 6, 12:37 pm, "Mark Rae [MVP]" <(E-Mail Removed)> wrote:
>> "Lit" <(E-Mail Removed)> wrote in message
>>
>> news:%(E-Mail Removed)...
>>
>> > Your code works fine on my machine.

>>
>> And on mine.
>>
>> > when I refresh the count goes, 1, 2, 3.....
>> > No loading twice.

>>
>> Same here.
>>
>> --
>> Mark Rae
>> ASP.NET MVPhttp://www.markrae.net

>
>



 
Reply With Quote
 
shailesh patel
Guest
Posts: n/a
 
      04-02-2010
I am aware of following two things.

If you have img control with empty string assigned to src attribute.
<img src=??/>
<asp:image runat=?server? id=?img?/>
You may be forgot to assign imageurl or wanted to assign imageurl in code behind based on the some condition and that condition never gets executed and ended up being empty string assigned to src attribute when ASP.Net renders the page.

If you have empty string assigned to href attribute to html link for stylsheet.
<link rel=?stylesheet? href=??/>

If you have empty src attribute set to script.
<script src=?? type=?text/javascript?>

for more information refer this article.
http://patelshailesh.com/index.php/p...h-firefox-only



George Ter-Saakov wrote:

I failed to understand reasoning why it's Visual Studio bug.....
06-Sep-07

I failed to understand reasoning why it's Visual Studio bug....

If the AutoEventsWireup is false then Page_Load is not wired as an even
handler. Your page is still called twice
Replac
protected void Page_Load(object sender, EventArgs e

wit

protected override void OnLoad(EventArgs e

and you will see that. Even with AutoEventsWireup = false

-----------------------------

You just learned today (and we did too

that having <img src=""> on a page.aspx is the same as having <img
src="page.aspx"

That is all

I would call it a browser's bug at most. But even that would be a stretch,
cause I am positive that behavior when src is empty is not determined in the
standard (never read it . But it's first time i come accross when someone
has empty src for image. If you need to make an invisible image just put
transparent gif 1x1 in there


George


"DBLWizard" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.com...

Previous Posts In This Thread:

On Thursday, September 06, 2007 12:53 PM
DBLWizard wrote:

ASP Image causes page to load twice
Howdy All

I need some help I can't believe this is bug in Visual Studio 2005 an
hasn't been reported yet, but I have recreated it on two differen
machines with the same result. I created a brand new website using V
2005 and the default.aspx page looks like this

<%@ Page Language="C#" AutoEventWireup="true
CodeBehind="WebForm1.aspx.cs" Inherits="Pgi.Hub.WebForm1" %

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"

<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
<title>Untitled Page</title
</head
<body
<form id="form1" runat="server"
<div
<asp:Image ID="imgTest" runat="server" /
<asp:Label ID="Label1" runat="server" Text="PageCount:"/
<asp:Label ID="Label2" runat="server" /
</div
</form
</body
</html

And the Default.aspx.cs page looks like this

using System
using System.Data
using System.Configuration
using System.Web
using System.Web.Security
using System.Web.UI
using System.Web.UI.WebControls
using System.Web.UI.WebControls.WebParts
using System.Web.UI.HtmlControls

public partial class _Default : System.Web.UI.Pag

protected void Page_Load(object sender, EventArgs e


if (Session["Default"] == null

Session["Default"] = 0


Session["Default"] = (int)Session["Default"] + 1
Label2.Text = Session["Default"].ToString()



The first time the page loads it displays PageCount:1 if you hi
refresh again it shows PageCount:3. If you put a break point in th
Page_Load it will hit the break point twice each time you load th
page. This seems to be tied to the Image control, because you ca
remove the <ASP:Image ...> entry from the page and it only load
once. Also it seems to be a ghost page because the the second tim
through the Label2.Text is set to 2 but the page that displays onl
says 1

I would appreciate any feedback or thoughts on what I'm doing wrong o
if there is some way around this and the best way to report it t
Microsoft if I'm not wrong

Thank

dbl

On Thursday, September 06, 2007 1:45 PM
George Ter-Saakov wrote:

Your code works fine on my machine. IE 7.What browser are you using?
Your code works fine on my machine. IE 7.
What browser are you using?
I suspect the problem is that you have Image control and no source fro image
(src) assigned.
So the generated HTML <img src=""> might trigger the request for the same
page.
Since browser trying to concatenate the src path with the path of the page
and I am not sure what is the rule when src is blank.

George.



"DBLWizard" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...

On Thursday, September 06, 2007 2:06 PM
Lit wrote:

Your code works fine on my machine.when I refresh the count goes, 1, 2, 3.....
Your code works fine on my machine.
when I refresh the count goes, 1, 2, 3.....
No loading twice.

create a new page and see may be you have some double subscription to your
events.
what happens if AutoEventWireup="true" is false?

Lit


"DBLWizard" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...

On Thursday, September 06, 2007 2:21 PM
DBLWizard wrote:

I question if "my" code works fine on your system.
I question if "my" code works fine on your system. If you are saying
that you added a ImageUrl property to the Image and then the problem
went away then I can buy that. But I don't think my code as I entered
it above works perfectly on your system unless its something that
Microsoft did differently in IE 7. I am running both IE 6 and Firefox
2.0.0.6 and they both exhibit the behavior.

I just added the ImageUrl property and an image and the problem went
away. It even goes away if you have something in the
ImageUrl(ImageUrl="abcdefg") but it doesn't resolve properly. But if
the is blank ImageUrl="" or the tag is not there the problem does
exist.

I also reduced my page down to:

<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<img id="Image2" src="" alt=""/>
</div>
</form>
</body>
</html>

And it double loads so its not a Visual Studio bug but it is a bizarre
behavior. So thanks for pointing me in the correct direction.

dbl

On Sep 6, 11:45 am, "George Ter-Saakov" <(E-Mail Removed)> wrote:

On Thursday, September 06, 2007 2:37 PM
Mark Rae [MVP] wrote:

Re: ASP Image causes page to load twice
And on mine.


Same here.


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

On Thursday, September 06, 2007 2:48 PM
George Ter-Saakov wrote:

Well, you got your answer.
Well, you got your answer. It's a browser problem
Browser IE 6 and Firefox does not know what to do with html like
<img src="">
they are "concatenating" empty string with the page's url and comes up with
the same URL. And sends "GET" request for that image.

But I am surprised in that behavior as well.

George.



"DBLWizard" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...

On Thursday, September 06, 2007 3:00 PM
DBLWizard wrote:

For everybody that this works fine with are ya'll using IE 7?
For everybody that this works fine with are ya'll using IE 7?

And I have decided that it still is a Visual Studio bug becuase if I
turn AutoEventsWireup to false the problem doesn't happen. Yes I know
that none of the events fire but still it is a bug in the event
handlers somewhere in Visual Studio. I don't have time at the moment
to dig into that and see exactly where the problem is as I have
already wasted a day trying to figure out what was causing this in the
first place ... but when I do I will try and add more details to this
post.

Thanks

dbl

On Sep 6, 12:37 pm, "Mark Rae [MVP]" <(E-Mail Removed)> wrote:

On Thursday, September 06, 2007 3:15 PM
Lit wrote:

I have IE 7 here. thanks for testing AutoEventsWireup.
I have IE 7 here. thanks for testing AutoEventsWireup.

Lit

On Thursday, September 06, 2007 3:44 PM
George Ter-Saakov wrote:

I failed to understand reasoning why it's Visual Studio bug.....
I failed to understand reasoning why it's Visual Studio bug.....

If the AutoEventsWireup is false then Page_Load is not wired as an even
handler. Your page is still called twice.
Replace
protected void Page_Load(object sender, EventArgs e)

with

protected override void OnLoad(EventArgs e)

and you will see that. Even with AutoEventsWireup = false.

------------------------------

You just learned today (and we did too)

that having <img src=""> on a page.aspx is the same as having <img
src="page.aspx">

That is all.

I would call it a browser's bug at most. But even that would be a stretch,
cause I am positive that behavior when src is empty is not determined in the
standard (never read it . But it's first time i come accross when someone
has empty src for image. If you need to make an invisible image just put
transparent gif 1x1 in there.



George.



"DBLWizard" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.com...


Submitted via EggHeadCafe - Software Developer Portal of Choice
BizTalk Configure and Send SMTP Mail Based on Message Within an Orchestration
http://www.eggheadcafe.com/tutorials...e-and-sen.aspx
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
asp.net page load twice problem Tony Dong ASP .Net 11 09-01-2011 07:38 PM
Response.ContentType = "image/jpeg" causes Page_Load Event twice Greg ASP .Net 4 10-19-2006 12:54 PM
twice(twice(x)) Kiuhnm C++ 2 04-01-2006 04:41 PM
Web Page Event causes page to refresh twice ? michaeltorus ASP .Net 0 11-25-2005 05:09 PM
Page load of the parent page called twice when a modal dialog is opened from a button click of the user control on the parent page Samy ASP .Net 2 08-15-2005 03:30 PM



Advertisments