难倒 - 页面有时会执行两次(偶尔会有三次!) [英] Stumped - page executes twice sometimes (even thrice occasionally!)

查看:70
本文介绍了难倒 - 页面有时会执行两次(偶尔会有三次!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网页表单Page1.asp它从数据库中读取数据,进行一些计算,并在页面中显示记录。工作正常。


我有一个显示在页面上的按钮,定义为< input type =" button"

onClick =" OutputData( )">


OutputData()函数是一个javascript函数,它只是这样做:


window.location =" Page1 .asp?Flag = 1";


这个重新执行 Page1.asp,但在查询字符串中设置了标志。 Page 1.asp中的

逻辑在设置此标志时将数据写入文件而不是将其分配给浏览器的
- 当该标志将NOTHING发送到浏览器时

已设置。


在生成数据文件结束时,Page1.asp对Page2执行Response.Redirect

.asp,在查询字符串中传递文件名。


Page2.asp使用我们在VB6中编写的COM对象(DLL)来进一步操作

数据和最终结果是一个PDF文件,它通过ADO二进制流中的
Response.BinaryWrite发送到浏览器。 Page2.asp输出没有HTML

本身 - 只有PDF数据。


让我难过的是Page2.asp正在执行多次_。

通常它执行两次,但有时会执行3次。我可以告诉

因为它使用的COM对象将一些信息写入日志文件。我清除了

日志文件,单击Page1.asp _one_ time上的按钮,日志显示连续执行2或3次的

COM对象。我无法弄清楚原因。
Page2.asp中没有循环 - 这是一个相当简单的ASP脚本,没有

函数或子' - 只有20左右脚本行。


Page1.asp绝对不会多次重定向到它。我在Page1.asp中放了一些

代码来记录每次重定向到Page2.asp时的时间戳。

它只在我点击按钮后* * *之后。


我在Page2.asp中添加了一些代码来增加一个Session变量,它确实会在点击后多次增加
,所以肯定是Page2。 asp

多次执行。我在Page1.asp中做了同样的事情,并且每次点击只需要一次增加



为什么会出现这种情况的想法?

I have a web form "Page1.asp" and it reads data from a database, does some
calculations, and displays the records in pages. Works fine.

I have a button that displays on the page, defined as <input type="button"
onClick="OutputData()">

The OutputData() function is a javascript function that simply does this:

window.location = "Page1.asp?Flag=1";

This "re-executes" Page1.asp, but with a flag set in the query string. The
logic in Page1.asp writes the data to a file when this flag is set instead
of paging it to the browser - it sends NOTHING to the browser when that flag
is set.

At the end of the data file generation, Page1.asp does a Response.Redirect
to Page2.asp, passing it the filename in the query string.

Page2.asp uses a COM object (DLL) we wrote in VB6 to further manipulate the
data and the end result is a PDF file that gets sent to the browser through
Response.BinaryWrite from an ADO binary stream. Page2.asp outputs no HTML
itself - only the PDF data.

What has me stumped is that Page2.asp is executing _multiple times_.
Usually it executes twice, but sometimes it executes 3 times. I can tell
because the COM object it uses writes some info to a log file. I clear the
log file, click on the button on Page1.asp _one_ time, and the log shows the
COM object being executed 2 or 3 times in a row. I cannot figure out why.
There are no loops in Page2.asp - it is a fairly simple ASP script, no
functions or sub''s - just about 20 lines of script.

Page1.asp is definitely not redirecting to it multiple times. I put some
code in Page1.asp to log a timestamp each time it redirects to Page2.asp and
it only does it *once* after I click the button.

I put some code in Page2.asp to increment a Session variable and it does
increment it multiple times after a click, so it is definitely Page2.asp
that is executing multiple times. I did the same in Page1.asp and it
increments only one time per click.

Any ideas why this might be happening?

推荐答案

Ken,


我检查了日志,它看起来像浏览器(或介于两者之间)

正在做两次:


2003-08-29 12:57:35 192.168.1.95用户名192.168.1.11 80 GET

/ virtualdir /Page1.asp

ReportID = 734& viewid = 226& title = Job%20List& RunTimeCr iteria =& Flag = 1 302

Mozilla / 4.0 +(兼容; + MSIE + 6.0; + Windows + NT + 5.0; +。NET + CL R + 1.0.3705)

2003-08-29 12:57:35 192.168.1.95用户名192.168.1.11 80 GET

/virtualdir/Page2.asp

Fn = C%3A%5CClientData%5Ctemp%5Crad5BCDC.tmp& Title = J ob%20List 200

Mozilla / 4.0 +(兼容; + MSIE + 6.0; + Windows + NT + 5.0; +。NET + CL R + 1.0.3705)

2003-08-29 12:57:37 192.168 .1.95用户名192.168.1.11 80 GET

/virtualdir/Page2.asp

Fn = C%3A%5CClientData%5Ctemp%5Crad5BCDC.tmp& Title = J ob%20List 200

Mozilla / 4.0 +(兼容; + MSIE + 6.0; + Windows + NT + 5.0; +。NET + CL R + 1.0.3705)


第一行是请求Page1.asp的地方(由window.location =""在

按钮的OnClick事件上执行的javascript代码。


第二行是Page1.asp由Response.Redirect请求的页面。


第三行是第二个请求的副本 - 我不知道为什么

出现了。


我不打算说这可能是一个逻辑错误,但我会感到惊讶 -

在Page1.asp中只有一个Response.Redirect而在Page2中没有。 asp -

查看代码,我可以想象甚至可能导致甚至

如果我想故意这样做。

Ken Schaefer <柯******* @ THISadOpenStatic.com>在留言中写道

news:e7 ************** @ tk2msftngp13.phx.gbl ...
Ken,

I checked the logs and it looks like the browser (or something in between)
is doing it twice:

2003-08-29 12:57:35 192.168.1.95 username 192.168.1.11 80 GET
/virtualdir/Page1.asp
ReportID=734&viewid=226&title=Job%20List&RunTimeCr iteria=&Flag=1 302
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CL R+1.0.3705)
2003-08-29 12:57:35 192.168.1.95 username 192.168.1.11 80 GET
/virtualdir/Page2.asp
Fn=C%3A%5CClientData%5Ctemp%5Crad5BCDC.tmp&Title=J ob%20List 200
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CL R+1.0.3705)
2003-08-29 12:57:37 192.168.1.95 username 192.168.1.11 80 GET
/virtualdir/Page2.asp
Fn=C%3A%5CClientData%5Ctemp%5Crad5BCDC.tmp&Title=J ob%20List 200
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CL R+1.0.3705)

The first line is where Page1.asp is requested (by the window.location="" in
the javascript code executed on the OnClick event for the button).

The second line is the page requested by the Response.Redirect by Page1.asp.

The third line is a duplicate of the second request - I don''t know why that
is showing up.

I don''t discount that it could be a logic error, but I would be suprised -
there is only one Response.Redirect in Page1.asp and none in Page2.asp -
looking at the code, I can imagine what could possibly even cause that even
if I wanted to do it on purpose.
"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:e7**************@tk2msftngp13.phx.gbl...
看看你的IIS日志 - 是浏览器多次请求
的页面(即浏览器是否发送了多个HTTP请求?)

如果没有,则会出现某种逻辑错误在您的编程代码中。

如果有多个HTTP请求被记录,那么浏览器
正在做一些有趣的事情,或浏览器和服务器之间的某些事情
(例如一些那种代理人正在做一些有趣的事情。

但是,至少这会帮助我们解决问题...

干杯


Manny <毫安*** @ keepyourspam.com>在消息中写道
新闻:%2 *************** @ TK2MSFTNGP12.phx.gbl ...
:我有一个网页表格Page1.asp ;并且它从数据库读取数据,执行
:计算,并在页面中显示记录。工作正常。

:我有一个显示在页面上的按钮,定义为< input
type =" button" :onClick =" OutputData()">

:OutputData()函数是一个javascript函数,只需要
这个::
:window.location = Page1.asp?Flag = 1;

:这个重新执行 Page1.asp,但在查询字符串中设置了一个标志。
:当这个标志设置为
时,Page1.asp中的逻辑将数据写入文件:将其分页到浏览器 - 当
标志设置为
时,它会向浏览器发送NOTHING。

:在生成数据文件的最后,Page1.asp执行
Response.Redirect:到Page2.asp,在查询字符串中传递文件名。

:Page2.asp使用我们在VB6中编写的COM对象(DLL)进一步操作

:数据和最终结果是一个PDF文件,它将被发送到浏览器
:来自ADO二进制流的Response.BinaryWrite。 Page2.asp输出没有
HTML:本身 - 只有PDF数据。

:让我难过的是Page2.asp正在执行多次_。
:通常执行两次,但有时会执行3次。我可以
告诉:因为它使用的COM对象将一些信息写入日志文件。我清除了
:日志文件,单击Page1.asp _one_时间上的按钮,日志显示
:COM对象正在执行2或3次行。我想不出
为什么。 :Page2.asp中没有循环 - 它是一个相当简单的ASP脚本,没有
:函数或子' - 只有大约20行脚本。

:Page1。 asp肯定不是多次重定向到它。我把
一些:在Page1.asp中的代码记录每次重定向到Page2.asp时的时间戳

:它只在我点击按钮后* * * * br />:
:我在Page2.asp中放了一些代码来增加一个Session变量,它确实
:点击后多次增加它,所以肯定是Page2.asp
:那个正在执行多次。我在Page1.asp中做了同样的事情并且它每次点击只增加一次。

:任何想法为什么会发生这种情况?


Have a look in your IIS log - is the page being requested multiple times by the browser (ie, is the browser sending multiple HTTP requests?)

If not, then there''s some kind of logical error in your programming code.

If there are multiple HTTP requests being logged, then either the browser is doing something funny, or something inbetween the browser and the server (eg some kind of proxy) is doing something funny.

But, at least this will help us isolate the problem...

Cheers
Ken
"Manny" <ma***@keepyourspam.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
: I have a web form "Page1.asp" and it reads data from a database, does some : calculations, and displays the records in pages. Works fine.
:
: I have a button that displays on the page, defined as <input type="button" : onClick="OutputData()">
:
: The OutputData() function is a javascript function that simply does this: :
: window.location = "Page1.asp?Flag=1";
:
: This "re-executes" Page1.asp, but with a flag set in the query string.
The
: logic in Page1.asp writes the data to a file when this flag is set instead : of paging it to the browser - it sends NOTHING to the browser when that
flag
: is set.
:
: At the end of the data file generation, Page1.asp does a Response.Redirect : to Page2.asp, passing it the filename in the query string.
:
: Page2.asp uses a COM object (DLL) we wrote in VB6 to further manipulate
the
: data and the end result is a PDF file that gets sent to the browser
through
: Response.BinaryWrite from an ADO binary stream. Page2.asp outputs no HTML : itself - only the PDF data.
:
: What has me stumped is that Page2.asp is executing _multiple times_.
: Usually it executes twice, but sometimes it executes 3 times. I can tell : because the COM object it uses writes some info to a log file. I clear
the
: log file, click on the button on Page1.asp _one_ time, and the log shows
the
: COM object being executed 2 or 3 times in a row. I cannot figure out why. : There are no loops in Page2.asp - it is a fairly simple ASP script, no
: functions or sub''s - just about 20 lines of script.
:
: Page1.asp is definitely not redirecting to it multiple times. I put some : code in Page1.asp to log a timestamp each time it redirects to Page2.asp
and
: it only does it *once* after I click the button.
:
: I put some code in Page2.asp to increment a Session variable and it does
: increment it multiple times after a click, so it is definitely Page2.asp
: that is executing multiple times. I did the same in Page1.asp and it
: increments only one time per click.
:
: Any ideas why this might be happening?
:
:



看着它,它看起来不像是一个逻辑错误 - 它绝对看起来像

喜欢浏览器发送两个相同的请求,相隔约2秒。

问题是为什么? :-)


我假设没有代理?另外,检查重复的

请求的HTTP状态 - 它们都是200(HTTP OK?)。也许PDF文件导致

浏览器回到服务器或其他东西?


(我会承认我有点难过! )


干杯



" JJ" < jj@nospam.com>在留言中写道

news:%2 **************** @ tk2msftngp13.phx.gbl ...

:Ken ,



:我检查了日志,它看起来像浏览器(或介于两者之间)

:正在做两次:< br $> b $ b:

:2003-08-29 12:57:35 192.168.1.95用户名192.168.1.11 80 GET

:/ virtualdir / Page1。 asp

:ReportID = 734& viewid = 226& title = Job%20List& RunTimeCr iteria =& Flag = 1 302

:Mozilla / 4.0 +(兼容; + MSIE + 6.0; + Windows + NT + 5.0; +。NET + CL R + 1.0.3705)

:2003-08-29 12:57:35 192.168.1.95用户名192.168.1.11 80 GET

:/virtualdir/Page2.asp

:Fn = C%3A%5CClientData%5Ctemp%5Crad5BCDC.tmp& Title = J ob%20List 200

:Mozilla / 4.0 +(兼容; + MSIE + 6.0; + Windows + NT + 5.0; + .NET + CL R + 1.0.3705)

:2003-08-29 12: 57:37 192.168.1.95用户名192.168.1.11 80 GET

:/virtualdir/Page2.asp

:Fn = C%3A%5CClientData%5Ctemp%5Crad5BCDC.tmp& Title = J ob%20Lis t 200

:Mozilla / 4.0 +(兼容; + MSIE + 6.0; + Windows + NT + 5.0; + .NET + CL R + 1.0.3705)



:第一行是请求Page1.asp的地方(由window.location =""

in

:javascript在按钮的OnClick事件上执行的代码。



:第二行是Response.Redirect请求的页面

Page1.asp。



:第三行是第二个请求的副本 - 我不知道为什么



:正在出现。



:我不打算这可能是一个逻辑错误,但我会感到惊讶 -

:Page1.asp中只有一个Response.Redirect,Page2.asp中没有一个 -

:查看代码,我可以想象甚至可能导致

甚至

:如果我是故意这样做的话。
Looking at that, it doesn''t look like a logic error - it definately looks
like the browser is sending two identical requests, about 2 seconds apart.
The question is "why?" :-)

I assume there''s no proxy? Also, check the HTTP status for the duplicate
requests - are they both 200 (HTTP OK?). Maybe PDF files are causing the
browser to go back to the server or something?

(I''ll admit that I''m a bit stumped!)

Cheers
Ken
"JJ" <jj@nospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
: Ken,
:
: I checked the logs and it looks like the browser (or something in between)
: is doing it twice:
:
: 2003-08-29 12:57:35 192.168.1.95 username 192.168.1.11 80 GET
: /virtualdir/Page1.asp
: ReportID=734&viewid=226&title=Job%20List&RunTimeCr iteria=&Flag=1 302
: Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CL R+1.0.3705)
: 2003-08-29 12:57:35 192.168.1.95 username 192.168.1.11 80 GET
: /virtualdir/Page2.asp
: Fn=C%3A%5CClientData%5Ctemp%5Crad5BCDC.tmp&Title=J ob%20List 200
: Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CL R+1.0.3705)
: 2003-08-29 12:57:37 192.168.1.95 username 192.168.1.11 80 GET
: /virtualdir/Page2.asp
: Fn=C%3A%5CClientData%5Ctemp%5Crad5BCDC.tmp&Title=J ob%20List 200
: Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CL R+1.0.3705)
:
: The first line is where Page1.asp is requested (by the window.location=""
in
: the javascript code executed on the OnClick event for the button).
:
: The second line is the page requested by the Response.Redirect by
Page1.asp.
:
: The third line is a duplicate of the second request - I don''t know why
that
: is showing up.
:
: I don''t discount that it could be a logic error, but I would be suprised -
: there is only one Response.Redirect in Page1.asp and none in Page2.asp -
: looking at the code, I can imagine what could possibly even cause that
even
: if I wanted to do it on purpose.


2003年8月28日星期四23: 06:22 - 0400,Manny <毫安*** @ keepyourspam.com>写道:
On Thu, 28 Aug 2003 23:06:22 -0400, "Manny" <ma***@keepyourspam.com> wrote:
我有一个网页表格Page1.asp它从数据库中读取数据,进行一些计算,并在页面中显示记录。工作正常。

我有一个显示在页面上的按钮,定义为< input type =" button"
onClick =" OutputData()">

OutputData()函数是一个javascript函数,它只是这样做:

window.location =" Page1.asp?Flag = 1";

这个重新执行 Page1.asp,但在查询字符串中设置了标志。当设置此标志而不是将其分页到浏览器时,Page1.asp中的
逻辑将数据写入文件 - 当设置该标志
时,它将NOTHING发送到浏览器。 br />
在生成数据文件的最后,Page1.asp对Page2.asp执行Response.Redirect,并在查询字符串中传递文件名。

Page2.asp使用我们在VB6中编写的COM对象(DLL)来进一步操作
数据,最终结果是一个PDF文件,通过ADO二进制流中的Response.BinaryWrite发送到浏览器。 Page2.asp本身不输出HTML本身 - 只有PDF数据。

我难倒的是Page2.asp正在执行多次_。
通常它执行两次,但有时候它执行3次。我可以告诉
因为它使用的COM对象将一些信息写入日志文件。我清除了
日志文件,单击Page1.asp _one_时间上的按钮,日志显示连续执行2或3次的COM对象。我无法弄清楚原因。 Page2.asp中没有循环 - 它是一个相当简单的ASP脚本,没有
函数或子' - 只有大约20行脚本。

Page1.asp肯定不会多次重定向到它。我在Page1.asp中放了一些
代码,每次重定向到Page2.asp时都会记录一个时间戳。
它只在我点击按钮后* * *。

我在Page2.asp中添加了一些代码来增加一个Session变量,并且它在点击后会多次增加它,所以它肯定是多次执行的Page2.asp
。我在Page1.asp中做了同样的事情,它每次点击只增加一次。

任何想法为什么会发生这种情况?
I have a web form "Page1.asp" and it reads data from a database, does some
calculations, and displays the records in pages. Works fine.

I have a button that displays on the page, defined as <input type="button"
onClick="OutputData()">

The OutputData() function is a javascript function that simply does this:

window.location = "Page1.asp?Flag=1";

This "re-executes" Page1.asp, but with a flag set in the query string. The
logic in Page1.asp writes the data to a file when this flag is set instead
of paging it to the browser - it sends NOTHING to the browser when that flag
is set.

At the end of the data file generation, Page1.asp does a Response.Redirect
to Page2.asp, passing it the filename in the query string.

Page2.asp uses a COM object (DLL) we wrote in VB6 to further manipulate the
data and the end result is a PDF file that gets sent to the browser through
Response.BinaryWrite from an ADO binary stream. Page2.asp outputs no HTML
itself - only the PDF data.

What has me stumped is that Page2.asp is executing _multiple times_.
Usually it executes twice, but sometimes it executes 3 times. I can tell
because the COM object it uses writes some info to a log file. I clear the
log file, click on the button on Page1.asp _one_ time, and the log shows the
COM object being executed 2 or 3 times in a row. I cannot figure out why.
There are no loops in Page2.asp - it is a fairly simple ASP script, no
functions or sub''s - just about 20 lines of script.

Page1.asp is definitely not redirecting to it multiple times. I put some
code in Page1.asp to log a timestamp each time it redirects to Page2.asp and
it only does it *once* after I click the button.

I put some code in Page2.asp to increment a Session variable and it does
increment it multiple times after a click, so it is definitely Page2.asp
that is executing multiple times. I did the same in Page1.asp and it
increments only one time per click.

Any ideas why this might be happening?



Manny ,

您的问题可能类似于我的问题。我只需点击一下按钮就可以将表单提交到

ASP页面,最终会提交两次
。我已经能够通过使用NETMON来确定交换的

数据包,在第一次正确提交后,客户端

然后执行另一次提交,这次使用cookie数据,这是
我假设服务器在第一次正确提交后正在询问。

奇怪的是,如果第一次提交使用GET作为方法,这似乎是

你的情况下,所有的表单数据都会被cookie数据重新提交,所以

一切都能满足我的需求..看看你能不能得到一个包

捕获并检查数据以进行第二次重定向,其中还包含cookie

数据。关闭Sessions也可以解决问题,

<%@ EnableSessionState = False%>

甚至只是为了看看cookie是否是罪魁祸首。

希望这会有所帮助,

TurboDuster


Manny,
Your problem MAY be similar to one I''m having. I submit a form to an
ASP page using a single button click, and it ends up getting submitted
twice. I''ve been able to determine by using NETMON to capture the
packets exchanged that after the first correct submission the client
then executes another submission, this time with cookie data, which
I assume the server is asking for right after the first correct submission.
Oddly, if the first submission used GET as a method, which seems to be
your case, all the form data gets resubmitted with the cookie data, so
everything actually works for my needs.. See if you can get a packet
capture and examine the data for a second redirect the also has cookie
data in it. Also turning Sessions off might solve the problem,
<%@ EnableSessionState = False %>
even just to see if cookies are the culprit.
Hope this helps,
TurboDuster


这篇关于难倒 - 页面有时会执行两次(偶尔会有三次!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆