Solved

Receive HTTP POST requests

Posted on 2014-10-01
7
259 Views
Last Modified: 2014-10-01
I need to receive HTTP POST requests, I thought I had it working but it turns out I was receiving GET instead of post. I have no experience in this and I am on quite a tight deadline.

What is the easiest way for me to get the posted data in to a text file? I was using a simple ASP code in IIS for the GET.


<%
Dim TN,FN,SN,RF, stext

Dim fs, file

fs=Server.CreateObject("Scripting.FileSystemObject")
file=fs.CreateTextFile("C:\approvedindex\upload\" & request.querystring("Reference") & ".txt",true)

TN = request.querystring("TradingName")
FN = request.querystring("firstname")
SN = request.querystring("surname")
RF = request.querystring("Reference")

file.write(TN)
file.write(",")
file.write(FN)
file.write(",")
file.write(SN)
file.write(",")
file.write(RF)


file.close
file=nothing
fs=nothing
 %>
Post Completed

Open in new window

0
Comment
Question by:CaptainGiblets
  • 3
  • 2
  • 2
7 Comments
 
LVL 27

Accepted Solution

by:
Dan McFadden earned 250 total points
ID: 40354100
Request.Querystring is accessing data from a HTTP GET.  You want to use Request.Form, Microsoft reference link:

http://msdn.microsoft.com/en-us/library/ms525985(v=vs.90).aspx

Just need to replace Request.Querystring  with Request.Form in the script.  This all assumes that the action is actually a HTTP POST.  If the inbound HTTP request is using a URL with querystrings, the Form collection will not work.

Dan
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 total points
ID: 40354104
If it's POST, it should be 'Request.Form' instead of 'request.querystring'.  More info here: http://www.w3schools.com/asp/asp_inputforms.asp
0
 
LVL 6

Author Comment

by:CaptainGiblets
ID: 40354108
So if I just update anything that says request.QueryString to request.form it should work the way it is?
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 27

Expert Comment

by:Dan McFadden
ID: 40354114
Yes.  Provided that the HTTP request is really arriving at the server as a POST.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40354115
Most likely, I don't see any reason it shouldn't.
0
 
LVL 6

Author Comment

by:CaptainGiblets
ID: 40354116
Great, updated the file and made a sample form post and it works. I will split between you as you have both been helpful.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40354133
Thanks.
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question