View Full Version : asp page executed twice ?!!!!
don_ankor
08-31-2006, 03:42 PM
hi all,
it's a big problem and i've been crashin my head for ages!
i have a pages that handles inserting records in a database
there is not much to say about that it's just inserting records
now i'm sure it's not an IIS issue i'm positive
it's that stupid IE requesting same page twice!!
because same test with FF1.5 works just fine !
i have tried everything it's a dead end
if anyone knows anything about this issue,pass it to me please
and just to mention in my page i don't have any images i've threw'wm all away(so no img src="") ,in fact nothing not even a link to a stylesheet nor a script so that should narrow possibilities
i have disabled sessionstate as well and set response.buffer to true (Microsoft's recommendations) but hell nothing ever works
screw Microsoft
10x
don_ankor
09-01-2006, 09:46 AM
i need some help here this is urgent
this is the code of my page without .css and .js files which i think may be causing the problem. i have also replaced the use of session variables with
form ones
<%@EnableSessionState=False%>
<%option explicit
Response.Buffer=true %>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<title>Untitled Document</title>
</head>
<% 'if session("key")<>"yes" then response.redirect("default.asp") %>
<!--#include file="connection.asp" -->
<!--#include file="mail.asp" -->
<!--#include file="attach.asp" -->
<!--#include file="mailbody.asp" -->
<%
randomize
'dim all recordsets
dim id,Rs1,Rs2,name2,Rs3
'dim all sql strings
dim SQL1,SQL3,SQL2,info3,info1,info2
'dim other variables
dim randomnumber,code1,mail1,name1,name2,mail2,phone2,rec_id,sessionArray
dim itemsArray,lastElt,qty,code,desc,unit,strDetails,innerHTML,from,mailBody,dcode1
sessionArray=split(request.form("session"),"~") ' session varaible replaced with form variable
randomnumber=cint(rnd()*10000)
If request.form("ex1")<>"yes" Then
SQL1=request.form("exist1")&randomnumber
objConn.execute "exec edrhd_insert " &SQL1,,129' a random number should be inserted in here as well
set id=objConn.execute("exec get_KeyId") ' get the autonumber value of the newely inserted donor
set Rs1=objConn.execute("exec donor_select_new "&id(0)) 'id("keyId")
code1=id(0)
mail1=Rs1("email")
name1=Rs1("donnor")
'response.write("<b>exist1 1 </b>:"+ request("exist1")+"<br/><b> newDonSql</b>"+SQL1)
Else
'response.write("<br/><b>exist12</b> :"&request.form("exist1")&"<br/>donorex "&request.form("ex1"))
code1=request.form("exist1")
set Rs1=objConn.execute("exec info1_select_new "&request.form("exist1"))
'response.Write(request.form("exist1")+"<br/>")
mail1=Rs1("email")
name1=request.form("name1")
end if
Info3=request.form("Rs2")
if request.form("exist2")<>"yes" then
Info3=Info3 & randomnumber
objConn.execute "exec Rs2_insert " &benInfo,,129
set id=objConn.execute("exec get_KeyId") ' id refers to benId
SQL3="exec Rs2_select_new "&id("keyId")
else
benSQL="exec Rs2_select_exist "&request.form("code2")
end if
set Rs2=objConn.execute(SQL3)
' another new change name2
name2=request.form("name2")
mail2=request.form("mail2")
phone2=request.form("rphone")
if request.form("ex2")="yes" then
id=request.form("exist3")
else
objConn.execute "exec insert_name2 '" & name2 & "','" &phone2& "','" &mail2& "'",,129
set name2=objConn.execute("exec get_keyId")
rec_id=name2("keyId")
name2.close()
set name2=Nothing
end if
SQL2=request.form("info1")&randomnumber&","&code1&","&Rs2("Rs2_code")& "," &rec_id
if request.form("dateFlag")<>"NoDate" then
objConn.execute "exec info1_insert " &SQL2,,129'
else
objConn.execute "exec info2_insert_noDate "&SQL2,,129
end if
set id=objConn.execute("exec get_KeyId")
set Rs3=objConn.execute("exec added_donation "&id("keyId"))
dcode1=Rs3("don_seq")
itemsArray=split(request.form("list"),"^")
lastElt=UBound(itemsArray)
dim quants(),Descs(),Units(),Amounts(),Curs(),i
redim quants(lastElt)
redim Descs(lastElt)
redim Units(lastElt)
redim Amounts(lastElt)
redim Curs(lastElt)
strDetails=""
for i=0 to lastElt
on error goto 0
qty=request.form("qty"&itemsArray(i))
quants(i)=qty
code=request.form("code"&itemsArray(i))
desc=request.form("desc"&itemsArray(i))
Descs(i)=desc
unit=request.form("unit"&itemsArray(i))
Units(i)=unit
Amounts(i)=request.form("amount"&itemsArray(i) )
Curs(i)=request.form("cur"&itemsArray(i) )
objConn.execute "exec edrdt_insert " & dcode1 & ",'" & code & "'," & qty & ",'" & desc & "','" & unit & "', " &Amounts(i) & ",'" &Curs(i) & "'",,129
next
from=request.form("agent")
mailBody=ConstructMailBody(dcode1,name1,Rs2("Rs2"),randomnumber,mail1,code1)
'synthax of calling the function to mail
'call sendMail(subject,from,receiver,mailBody,"C:\TempAttachments\ref"&dcode1&".html","t2@domain.com.,Rs2("email"),from)
call sendMail("subject",from,mail1,mailBody,"C:\TempAttachments\ref"&dcode1&".html","t2@domain.com",Rs2("email"),from,mail2)
set objConn=nothing
%>
<title>Thank You</title>
<script language="JavaScript" type="text/javascript">
var sWinHTML="<%=innerHTML%>"
function printPage()
{
var winprint=window.createPopup();
winprint.document.open();
winprint.document.write(sWinHTML);
winprint.document.close();
winprint.show(10,30,screen.width,screen.height)
}
</script>
</head><body>
<table border=0 cellspacing=0 cellpadding=0 width=710>
<tr>
<td colspan=2 align="center"><h1>Thank you for your concern </h1></td>
</tr>
<tr>
<td colspan=2 height="1"></td>
</tr>
<tr>
<td colspan=2> your own reference <strong><%=dcode1%></strong> <a href="javascript:printPage()">Print Preview >></a></td>
</tr>
<tr>
<td colspan=2 height="20">An email will soon be sent to <strong><%=mail1%></strong> containing tracking info.</td>
</tr>
<tr>
<td colspan=2>
</td>
</tr>
<tr>
<td colspan=2 height="20">Some useful websites : </td>
</tr>
<tr>
<td colspan=2 height="20"></td>
</tr>
<tr>
<td><table border=0 cellspacing=0 cellpadding=0>
<tr>
<td class=Linkbold><a href="http://www.website1.com/">website1</a></td>
</tr>
<tr>
<td height="10"></td>
</tr>
<tr>
<td></td>
</tr>
</table></td>
<td><table border=0 cellspacing=0 cellpadding=0>
<tr>
<td class=Linkbold><a href="http://www.website2.com">website2</a></td>
</tr>
<tr>
<td height="10"></td>
</tr>
<tr>
<td></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td align="right"> <input name="more" type="button" value="Close this Window" onClick="window.close()" /></td>
<td> </td>
</tr>
<tr>
<td height="20" colspan="2" align="center"> </td>
</tr>
<tr>
<td colspan=2> </td>
</tr>
</table>
</body>
</html>
<%
Rs3.close()
Rs1.close()
Rs2.close()
set Rs3=nothing
set Rs1=nothing
set Rs2=nothing
Response.Write(Request.ServerVariables("ALL_HTTP"))
'Attachment.deleteFile("C:\TempAttachments\ref"&dcode1&".html")
%>
the http header contains nothing unusual here it is
HTTP_ACCEPT:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* HTTP_ACCEPT_LANGUAGE:en-us HTTP_CONNECTION:Keep-Alive HTTP_HOST:localhost HTTP_REFERER:http://localhost/edr/register.asp HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) HTTP_COOKIE:ASPSESSIONIDQAQADCAQ=NMODNFPDCLDOGEGHIGMAKOKN HTTP_CONTENT_LENGTH:680 HTTP_CONTENT_TYPE:application/x-www-form-urlencoded HTTP_ACCEPT_ENCODING:gzip, deflate HTTP_CACHE_CONTROL:no-cache
heeeeeelp!!!!!!
don_ankor
09-02-2006, 07:18 PM
Jesus Christ people
does anybody have a clue or betta
does any body care?
Spudhead
09-04-2006, 03:56 PM
Jesus Christ people
does anybody have a clue or betta
does any body care?
Firstly, don't use language like that. There's no need for it, and it's certainly not going to improve your chances of a reply.
Secondly:
Right, where to start? It's not clear from your initial post what the problem actually IS. There's something about a page that inserts records, an impression that this isn't the desired behaviour, and the suggestion that this isn't, in fact, a server-side issue at all but is rather due to an unspecified bug in IE that requests pages twice.
So: rule one = explain what the problem is. Describe what is happening, what should be happening, and how those are different. Post up any relevant debug output, explain the solutions you've tried so far and why they didn't work as expected.
Next: posting the code is great, but Not Like That. If you have an issue with (I'm guessing) duplicate records going into a database, don't post a page full of HTML. I'm not interested in that bit. I want to see your record-inserting code, on its own, without having to read through two hundred unformatted lines of irrelevant code.
And, while we're at it, post ALL the relevant bits of code. If you're using stored procs to do the insert, post the stored procs. I can tell much more about what might be going wrong from that than I can from a HTML table.
So : rule 2 = post carefully selected chunks of code that show the entire process, and explain what's happening, why you've done it in that way and what happens when you change bits.
With that in mind, could you explain exactly what's happening, which bit of ASP code isn't functioning as intended, and if possible a bit more debug output of exactly which SQL statements are being executed.
don_ankor
09-05-2006, 10:07 PM
ok whateva man
the problem is i dunno where the problem is !!,
the whole script is executed twice and im so sure it's not a webserver issue
because it works smoothly in FireFox
i'm not able yet to precisely time it or even narrow possibilities
i'm using an access database and all the SP's are executed, i can tell from my database , i tried isolating each one apart but the same thing happens with each
anyways
here are the SPs from bottom to top as used in the page:
* edrdt_insert INSERT INTO edrdt ( don_ref, item_detail, qty_detail, detail, mes_unit, amount_detail, cur_detail )
VALUES ([@donationCode], [@code], [@qty], [@desc], [@unit], [@amount_detail], [@cur_detail]);
* added_donation :select don_id from donations where don_seq=[@id]
* info1_insert :INSERT INTO edrdn ( brief_desc, bp, trans, stat, ownref, original_destination, groupset, groupto, deleted, entry_date, exp_date, randomnumber, don_id, rec_id, oper_id)
VALUES ([@brief_desc], [@bp], [@trans_dn], [@stat_dn], [@ownref_dn], [@nameset_dn], [@groupset_dn], [@groupto_dn], [@deleted_dn], [@entry_date_dn], [@exp_date_dn], [@randomnum_dn], [@don_id_dn], [@rec_id_dn], [@oper_id_dn]);
* info2_insert_noDate is just the same but without dates
*insert_name2 :INSERT INTO edrop ( name, phone, email )
VALUES ([@name], [@phone], [@email]);
*Rs2_select_exist: SELECT name, address, phone, fax, email, contact, website, rec_id FROM edrrc WHERE rec_id=[@code];
*Rs2_insert :INSERT INTO edrrc ( name, address, phone, fax, email, contact, website, randomnum )
VALUES ([beneficiary], [address], [phone], [fax], [email], [contact_person], [website], [randomnum]);
*info1_select_new : SELECT name, country, address, phone, fax, email, contact, website
FROM edrhd
WHERE don_id=[@id];
*edrhd_insert :INSERT INTO edrhd ( name, country, address, phone, fax, email, contact, website, randomnum )
VALUES ([@name], [@country], [@address], [@phone], [@fax], [@email], [@contact], [@website], [@randomnum]);
ok that's all for the SPs
server side includes
==mail.asp==
<%
sub sendMail(subject,from,receiver,mailBody,attachment,cc,cc2,cc3,cc4)
if cc="" then cc="test@srvsca.com"
dim Mail
Set Mail=Server.CreateObject("CDO.Message")
Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="172.27.16.74"
'Server port
Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
Mail.Subject=subject
Mail.From=from
Mail.To=receiver
if cc2<>"" then cc=cc&";"&cc2
if cc3<>"" then cc=cc&";"&cc3
if cc4<>"" then cc=cc&";"&cc4
Mail.Cc=cc
Mail.HTMLBody=mailBody
Mail.AddAttachment attachment
Mail.Fields("urn:schemas:httpmail:importance").Value = 2
Mail.Fields.Update()
Mail.Send
set Mail= nothing
end sub
========================================================
==mailbody.asp==
i'm posting html again i'm using an MS Word formatted e-mail message,i dunno it could be this that's driving IE crazy,but that's a normal string not to be output to the browser
=====================================================================
function constructMailBody(code,dn_name,dr_name,randomnumber,dn_email,dn_code)
dim str,Rs
set Rs=objConn.execute("select d.randomnumber from donation d,edrhd e where e.don_id=d.don_id and e.email='"&dn_email&"'")
randomnumber=Rs.getString(,,,"0","")
str="<html>"&_
"<head>"&_
"<style>"&_
"<!--/* Font Definitions */"&_
" @font-face"&_
" {font-family:Tahoma;"&_
" panose-1:2 11 6 4 3 5 4 4 2 4;}"&_
"@font-face"&_
" {font-family:Garamond;"&_
" panose-1:2 2 4 4 3 3 1 1 8 3;}"&_
" /* Style Definitions */"&_
" p.MsoNormal, li.MsoNormal, div.MsoNormal"&_
" {margin:0in;"&_
" margin-bottom:.0001pt;"&_
" 'font-size:8.0pt;"&_
" font-family:Tahoma;}"&_
"h1"&_
" {margin-top:0in;"&_
" margin-right:0in;"&_
" margin-bottom:10.0pt;"&_
" margin-left:0in;"&_
" font-size:22.0pt;"&_
" font-family:Tahoma;"&_
" text-transform:uppercase;"&_
" font-weight:normal;}"&_
"h2"&_
" {margin:0in;"&_
" margin-bottom:.0001pt;"&_
" font-size:50.0pt;"&_
" font-family:Tahoma;"&_
" color:#99BABD;"&_
" font-weight:normal;}"&_
"a:link, span.MsoHyperlink"&_
" {color:blue;"&_
" text-decoration:underline;}"&_
"a:visited, span.MsoHyperlinkFollowed"&_
" {color:purple;"&_
" text-decoration:underline;}"&_
"p"&_
" {mso-margin-top-alt:auto;"&_
" margin-right:0in;"&_
" mso-margin-bottom-alt:auto;"&_
" margin-left:0in;"&_
" font-size:12.0pt;"&_
" font-family:'Times New Roman';}"&_
"p.allcaps, li.allcaps, div.allcaps"&_
" {margin-top:2.0pt;"&_
" margin-right:0in;"&_
" margin-bottom:0in;"&_
" margin-left:0in;"&_
" margin-bottom:.0001pt;"&_
" font-size:8.0pt;"&_
" font-family:Tahoma;"&_
" text-transform:uppercase;}"&_
"span.allcapschar"&_
" {font-family:Tahoma;"&_
" text-transform:uppercase;}"&_
"span.EmailStyle20"&_
" {mso-style-type:personal;"&_
" font-family:'Courier New';"&_
" color:blue;"&_
" font-weight:normal;"&_
" font-style:normal;"&_
" text-decoration:none none;}"&_
"span.EmailStyle21"&_
" {mso-style-type:personal;"&_
" font-family:Arial;"&_
" color:navy;}"&_
"span.EmailStyle23"&_
" {mso-style-type:personal-reply;"&_
" font-family:Arial;"&_
" color:navy;}"&_
"@page Section1"&_
" {size:595.3pt 841.9pt;"&_
" margin:1.0in 1.25in 1.0in 1.25in;}"&_
"div.Section1"&_
" {page:Section1;}"&_
".style1 {font-size: 12.0pt}"&_
"-->"&_
"</style>"&_
"</head>"&_
"<body>"&_
"<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0>"&_
" <tr>"&_
" <td width=636 colspan=2 valign=bottom style='width:477.0pt;padding:0in 0in 0in 0in'>"&_
"<p dir=LTR><strong><b><font size=7 color=blue face=Tahoma><span"&_
" style='font-size:36.0pt;font-family:Garamond;color:blue'>The Lebanese"&_
" Government</span></font></b></strong><font size=7><span style='font-size:"&_
" 36.0pt'><o:p></o:p></span></font></p>"&_
" <h2 dir=LTR><font size=7 color=blue face=Garamond><span style='font-size:30.0pt;"&_
" color:blue'>Reference has been issued</span></font><font"&_
" size=7><span style='font-size:30.0pt'><o:p></o:p></span></font></h2>"&_
" </td>"&_
" </tr>"&_
" <tr height=136 style='height:101.8pt'>"&_
" <td width=636 colspan=2 height=136 valign=top style='width:477.0pt;"&_
" padding:0in 0in 0in 0in;height:101.8pt'>"&_
" <p class=allcaps dir=LTR><strong><b><font size=1 color=blue face=Tahoma><span"&_
" style='font-size:8.0pt;font-family:Tahoma;color:blue'><o:p> </o:p></span></font></b></strong></p>"&_
" <p class=allcaps dir=LTR><strong><b><font size=3 color=blue face=Tahoma><span"&_
" style='font-size:12.0pt;font-family:Tahoma;color:blue'>EDR"&_
" Ref </span></font></b></strong><strong><b><font "&_
" size=3 face=Tahoma><span style='font-size:12.0pt;font-family:Tahoma'>:</span></font></b></strong>"&_
" <font size=3 color=blue><span style='font-size:12.0pt;font-family:Georgia;color:blue'><i>" & code& "</i></span></font> "&_
" <o:p></o:p></p> "&_
" <p class=allcaps dir=LTR><strong><b><font size=3 color=blue face=Tahoma><span "&_
" style='font-size:12.0pt;font-family:Tahoma;color:blue'>EDR "&_
" DATE </span></font></b></strong><strong><b><font "&_
" size=3 face=Tahoma><span style='font-size:12.0pt;font-family:Tahoma'>:</span></font></b></strong> "&_
" <font size=3 color=blue><span style='font-size:12.0pt;font-family:Georgia;color:blue'><i>" & date() & "</i></span></font>"&_
" <o:p></o:p></p>"&_
" <p class=allcaps dir=LTR><strong><b><font size=3 color=blue face=Tahoma><span "&_
" style='font-size:12.0pt;font-family:Tahoma;color:blue'>Sender "&_
" </span></font></b></strong><strong><b><font size=3 face=Tahoma><span "&_
" style='font-size:12.0pt;font-family:Tahoma'> :</span></font></b></strong> <font "&_
" size=3 color=blue><span style='font-size:12.0pt;font-family:Georgia;color:blue'><i>"&dn_name&"</i></span></font>"&_
" <o:p></o:p></p>"&_
" <p class=allcaps dir=LTR><strong><b><font size=3 color=blue face=Tahoma><span "&_
" style='font-size:12.0pt;font-family:Tahoma;color:blue'>Received by</span></font><span class='style1'><font color=blue><span "&_
" style='font-family:Tahoma;color:blue'> </span></font></span><font "&_
" size=3 face=Tahoma> :</font></b></strong> "&_
" <o:p></o:p><i><span style='font-size:12.0pt;font-family:Georgia;color:blue;'>"&dr_name&"</span></i></p> "&_
" <p class=allcaps dir=LTR><font size=1 face=Tahoma><span style='font-size: "&_
" 8.0pt'><o:p> </o:p></span></font></p>"&_
" </td>"&_
" </tr> </table>"&_
constructMailBody=str
'response.Write(randomnumber)
end function
%>
========================================================
==attach .asp==
is simply a file that writes an attachment file to the server's disk and then
posts its contents to a javascript variable in order to generate a preview
graficus
09-06-2006, 12:29 AM
Maybe you should get rid of the popup and do the whole thing in main page?
Brandoe85
09-06-2006, 04:50 AM
don_ankor (http://www.codingforums.com/member.php?u=38685)
Spudhead is right, there is absolutley no need to react like that. People are devoting their time on these forums to help. Rudeness like that gets you exactly what you've gotten. No help.
don_ankor
09-06-2006, 07:33 AM
look man i did not mean to be rude aight
it's just this problem was getting on my nerves ok
i'm sorry ok
i hope everything is cool ,
if you wanna give help you're welcome anf if not it's ok i'm not gunna kill myself over it
thanks for y'all for your time
ok i ran some more debugging on this:
i initiated a session in default.asp that calls register.asp(the script being executed twice):
==default .asp==
session("randomnumber")=4587
and session("randomnumber"), after being used in register.asp, is removed from session
==register.asp==
exec insert ... "&session("randomnumber")
session.contents.removeAll()
================================================================
so when executed,the page generates a "data type mismatch" error
but when i query my database, i see that arecord is inserted,which means that it did a 1st insert,removed the key,did a second and got an error!!
and further more my IIS log file clearly shows 2 http request
---------------------------------------------------------------
relevant to default.asp
___________________
08:55:08 127.0.0.1 POST /edr/default.asp 200
08:55:08 127.0.0.1 GET /edr/stylesheets/cs_default.css 304
08:55:08 127.0.0.1 GET /edr/scripts/popUp.js 304
08:55:08 127.0.0.1 GET /edr/scripts/js_edit.js 304
relevant to register.asp
____________________
08:55:23 127.0.0.1 POST /edr/register.asp 200
08:55:23 127.0.0.1 POST /edr/register.asp 200
08:55:23 127.0.0.1 GET /edr/stylesheets/print.css 304
---------------------------------------------------------------
that is after i disabled evey single sql statement in register.asp
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.