Avatar of net-workx
net-workx
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Script works until the .asp filename changes

This one has had be stuck literally for 10 hours soild and i still dont have a clue what is causing it.

I have an asp script file which resides in the location:

/common/sagepay/notificationPage.asp

This file has things "POST"ed to it from a form/third party system and this script does something with the posted data.  (before its suggested changing the submission to a GET is not possible.

The code in the file does a Request.Form("FieldName") and then does something with the data, the problem was that the Request.Form isnt pulling the data from the submission, even though it is definatly being sent to the script.  I was scratching my head for hours on this one and can tell you that:

If i move the notificationPage.asp code up a level in the directory tree, or put it in the root of the site, the code still does not work.  If i remove all other code from the file and just do a simple Response.Write of one of the submitted fields, it does not work.

If however i change the file name from notificationPage.asp to results.asp or anything other (like x.asp etc) then the the Request.Form works.

rename the file back to notificationPage.asp and it stops working again.

I have recreated the code files in notepad through the code editor to ensure not permission issues or anything bizzare but still no joy.

Am i being stupid and missing something simple?  Can anyone shed some light?!!!
ASP

Avatar of undefined
Last Comment
net-workx

8/22/2022 - Mon
SOLUTION
Scott Fell

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
net-workx

ASKER
Sorry, the GET is working fine but i only did this from a test page, its a bit of a red herring in the description above and GET can be disregarded for the remainder of the discussion on this problem.

We are using POST only along with Request.Form.

A clearer description here would be that the code in notificationPage.asp didnt appear to be reading anything that was posted to it, i thought the post which was being sent to it was faulty.

I have done NOTHING else to the code but changed the physical file name of the code file on the server to notification.asp - the code is now working and Request.Form is doing what it should do, returning the values from the post.

The page they are posting to is: http://test.domain.co.uk/common/sagepay/notificationPage.asp (not working) but
http://test.domain.co.uk/common/sagepay/notification.asp  (is working)

Does this make things clearer?
SOLUTION
Dave Baldwin

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
net-workx

ASKER
@DaveBaldwin - i also agree with padas its confusing... hence why ive been looking at it for 10 hours trying to sort the problem out!  Its driving me insane!

I have just replied to padas but to confirm:

http://test.domain.co.uk/common/sagepay/notificationPage.asp - Does not work
http://test.domain.co.uk/common/sagepay/notification.asp  - Works correctly

The code is IDENTICAL - no changes to the code in the .asp page what-so-ever.

Does this make things clearer?
Dave Baldwin

No because you haven't shown us the code for the form or for the page.  If what you say is true that the code is identical, then the first page doesn't work because it isn't in the 'action' for the form.  The data from the form and the action page have to match.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
net-workx

ASKER
@DaveBaldwin

1) A simple request.form could be in the file, it does not work.  As a quick test to prove my theory here are two samples which work when places in root/test/form but dont work when in root/common/sagepay and the results.asp is renamed to notificationPage.asp

<form method="post" action="/common/sagepay/result.asp">
    <input type="text" name="test1" />
   <input type="hidden" name="Status" id="Status" value="OK">
   <input type="hidden" name="VendorTxCode" value="10-10-WEB-1000">
   <input type="text" name="VendorTxCode1" value="10-10-WEB-1000">

    <input type="submit" value="Submit" />
</form>
<%
test1 = Request.Form("test1")
Status = Request.Form("Status")
VendorTxCode = Request.Form("VendorTxCode")
VendorTxCode1 = Request.Form("VendorTxCode1")

Response.Write "test1: " & test1 & "<br>"
Response.Write "Status: " & Status & "<br>"
Response.Write "VendorTxCode: " & VendorTxCode & "<br>"
Response.Write "VendorTxCode1: " & VendorTxCode1 & "<br>"

 %>

2) " If what you say is true that the code is identical" - please dont question is what im saying is true.  I said they were identical, and they are.  In fact the file was copied and renamed, the contents ARE identical. FACT.

3) It is nothing to do with the 'action' for the form.. you can change the action to point to any file on the server with the code:
<%
test1 = Request.Form("test1")
Status = Request.Form("Status")
VendorTxCode = Request.Form("VendorTxCode")
VendorTxCode1 = Request.Form("VendorTxCode1")

Response.Write "test1: " & test1 & "<br>"
Response.Write "Status: " & Status & "<br>"
Response.Write "VendorTxCode: " & VendorTxCode & "<br>"
Response.Write "VendorTxCode1: " & VendorTxCode1 & "<br>"

 %>
and it will work correctly, but put it in the /sagepay/notificationPage.asp and it does not work.

Incidentally, the real code i want to work isnt that posted, its much more complex but if this simple form and results page dont work then the other code isnt going to work either - ive kept it simple to help narrow down the fault.

Thanks
net-workx

ASKER
I have just changed the actual code file name from notificationPage.asp to notification.asp and it looks like all working ok.

Remember, the code hasnt changed at all.

I guess i could leave it at that file name, but thats not the point now... i would like to know whats caused it.

Any ideas?
Scott Fell

Let's say you take the code below for simplicity and copy it to  http://test.domain.co.uk/common/sagepay/notificationPage.asp then Save As the identical page to http://test.domain.co.uk/common/sagepay/notification.asp 

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>

<body>
<%
if request("item")<>"" then
	response.write "Item: "&request("Item")
	else
	response.write "Nothing posted"
end if
%>
</body>
</html

Open in new window


Now create a third page with the code below and save to http://test.domain.co.uk/common/sagepay/formtest.asp.  For simplicity, let's keep the action to the full url.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>

<body>
<form name="form1" method="post" action="http://test.domain.co.uk/common/sagepay/notificationPage.asp">
<input name="item" type="text" value="hello">
<input type="submit" name="button" id="button" value="Submit">
</form>
<hr>
<form name="form1" method="post" action="http://test.domain.co.uk/common/sagepay/notification.asp">
<input name="item" type="text" value="hello">
<input type="submit" name="button" id="button" value="Submit">
</form>

</body>
</html>

Open in new window


A) what happens now when you surf to http://test.domain.co.uk/common/sagepay/notificationPage.asp

On this first test, if you are not even getting the message, "Nothing posted" then something is stuck in the cache.  Can you try resetting the application pool or turning iis off then on?

b) What happens when you surf to http://test.domain.co.uk/common/sagepay/notification.asp

c) What happens when you go to http://test.domain.co.uk/common/sagepay/formtest.asp and click the top button?  the bottom button?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Dave Baldwin

Your point #1 is exactly what I would suggest for a test.  As for #2, I question everything because I've heard every story here on EE and many of them turned out not to be exactly true by the end of the question.  Your point #3 is exactly making my point that the form and 'action' page have to match.

So it sounds like you have done exactly what I would have done.  At this point, I would use Firefox and LiveHTTP Headers addon to see if the form page is posting Exactly what it should be and that the action page is giving the expected response.  Theoretically, 'notificationPage.asp' and 'notification.asp' should cause the same response headers.  Since they are not displaying the same, you have to look past the page and at the other things that happen on the server.
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
net-workx

ASKER
Never got to the bottom of this, i renamed the file and code to point to the new file as ran out of time for diagnosis on it.

Points awarded equally to as compensation all people involved and their effort.