Debug causes double postback

G

Guest

My environment. .Net 2.0 VS2k5 SP1, IE6 (6.0.2900.2180)

I have a web content page. The page will post back twice if I am running in
debug mode. However if I run through the breakpoints fast enough the page
will not post back twice.

I have disabled Google Popup blocker, windows firewall, a soap collector
service.

Something wierd with IE is if I sit in debug long enough the page will go
blank and the status bar will say something along the lines of "Looking for
localhost".

If I run through the breakpoints fast enough, and the blank IE page never
shows up, then the double postback doesn't occur.

It seems as if IE is automatically posting back if the request is taking too
long.

What can I do?
 
S

Steven Cheng[MSFT]

Hi Mike,

Based on your description, I think the double postback issue is actually
occuring when your server-side code will block/wait for a while rather than
execute immediately, so the "under debugging mode" is only a condition
which trigger this cause.

For ASP.NET web page double postback, I've also met some similar issues
before and here are some of the causes:

** Some html markup (such as the meta fresh tag or a <img> or css image
style ) that point to the page itself which cause an additional get postback

** certain server-side event handler be registered twice(usually in vb.net
web page)

** some control may cause postback event be submit twice(the SubmitButton
which configured as image style...)

for your scenario, I think one possible cause is your page's response will
write out some certain html tag that cause a new request to the page
itself. Since it will occur when you wait a while at server-side(such as
break at debugger), maybe at that time, the markup is send back to client
and the browser send a new request). You can check the following things to
further verify the behavior:

1) Check IIS log on the server and see what kind of request is the second
duplicated one(get or post)

2) Check whether all the page events are executed twice or only the
particular postback event

If you have any other finding, please also feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Hello Steven,

I checked the IIS logs. Here is what I saw in the first pass:

10:06:45 127.0.0.1 GET /Application1/Page1.aspx 401
10:06:54 127.0.0.1 GET /Application1/Page1.aspx 200
10:06:57 127.0.0.1 POST /FormService/FormService.asmx 200
10:07:03 127.0.0.1 GET /css/css1.css 404
10:07:03 127.0.0.1 GET /Application1/Page1.aspx 200
10:07:07 127.0.0.1 DEBUG /Application1/NewForm.aspx 200

I saw the 404 for the CSS file, I know where it is occurring...removing it
from the page. Tried again and go this.

10:37:01 127.0.0.1 GET /Application1/Page1.aspx 401
10:37:07 127.0.0.1 GET /Application1/Page1.aspx 200
10:37:11 127.0.0.1 POST /TestService/TestService.asmx 200
10:37:18 127.0.0.1 GET
/Application1/PetersDatePackage/Appearance/stylesheet1.css 401
10:37:18 127.0.0.1 GET
/Application1/PetersDatePackage/Appearance/stylesheet1.css 304
10:37:18 127.0.0.1 GET /Application1/Page1.aspx 200
10:37:18 127.0.0.1 GET /Application1/PetersDatePackage/1_1_12/PDP_Globals.js
304
10:37:18 127.0.0.1 GET /Application1/PetersDatePackage/1_1_12/DateTextBox.js
304
10:37:18 127.0.0.1 GET /Application1/PetersDatePackage/1_1_12/CSCalendar.js
304
10:37:18 127.0.0.1 GET
/Application1/PetersDatePackage/1_1_12/CSMonthPicker.js 304
10:37:18 127.0.0.1 GET /Application1/PetersDatePackage/1_1_12/CS_Menu.js 304


If I run through fast enough on the page, the page load event is only fired
once. However it seems like if I don't get my debugging done before the IE
screen goes blank and the status bar changes to the "searching for localhost"
then the page load event is hit twice.

When you say Page Events....do you mean true page events like Init Load,
Render?

Also, just as an fyi, I am registering to a published event on a web
control. The web control has buttons on it and I am doing the processing for
them on the hosting page. Code is below.

Private Sub Page1_Init(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Init
AddHandler WebControl1.ActionClickEvent, AddressOf OnFormAction
End Sub
 
G

Guest

Yeah that is what I thought it was at first, but I checked. It is false for
the content page. It is not defined on the master page, but I don't think
you could set it at that level anyway.

<%@ Page Language="vb" AutoEventWireup="false"
MasterPageFile="~/master_pages/default.master"
Codebehind="Page1.aspx.vb" Inherits="Application1.Page1" Title="Untitled
Page"
Culture="auto" %>


Thanks,
 
S

Steven Cheng[MSFT]

Thanks for your reply Mike,

so "Page1.aspx" is the one in problem, right? From the log you provided,
there are only multiple "get" requests, so the double "Page_load" occurs
at the first load of the page?

Yes, the page events I mentioned earlier means those standard built-in Page
events(Init, Load, Prerender....).

I'm still quite interested in the "browser turn to blank behavior", not
sure whether it is caused by client-side browser or some html element
flushed from server-side. I'd like to perform some test on my local side,
if the problem does be caused by some element flushed by server-side page,
it should be reproable on my side. Would you try make a simplified page
that can repro the problem and send it to me? You can reach me through the
email in my signature(remove "online" in it).

Looking forward to your reply.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Steven Cheng[MSFT]

Hi Mike,

Have you got any further progress on this issue? If there is still
anything need help, please don't hesitate to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top