I've got two scripts on a windows server, setup to receive data from a post.
我在windows服务器上有两个脚本,用于从post接收数据。
One is a PHP file that works.
一个是可以工作的PHP文件。
<?php
echo "Hello! <br/> This is a Post Back script that writes to a text file!";
// retrieving information from Post Back
$accounting = $_POST["accountingAmount"];
$accounting_txt = "accounting: " . "$accounting" . "\n\n";
$address1 = $_POST["address1"];
// LOTS MORE FIELDS //
$address1_txt = "address1: " . "$address1" . "\n\n";
"$recurPrice_txt" . "$referer_txt" . "$referringUrl_txt" . "$reservationId_txt" . "$responseDigest_txt" . "$start_date_txt" . "$state_txt" . "$sub_id_txt" . "$typId_txt" . "$username_txt" . "$zipcode_txt";
// write to a text file
$myFile = "postback.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $message;
fwrite($fh, $stringData);
fclose($fh);
?>
The ASP.NET MVC script is this:
ASP。NET MVC脚本如下:
[HttpPost]
public ActionResult approved(FormCollection formValues)
{
var context = new LSmixDbEntities();
PaymentHistory ph = new PaymentHistory();
StringBuilder s = new StringBuilder();
foreach (string key in Request.Form.Keys)
{
s.AppendLine(key + ": " + Request.Form[key] + Environment.NewLine);
}
string formData = s.ToString();
//save formData in db
}
I tested by putting vs on the server itself and breakpointing, the action doesn't even start.
我通过在服务器上设置vs和断点进行测试,操作甚至都没有开始。
Is there any reason a .php file would be hit by a remote postback, but an MVC action wouldn't be?
是否有任何原因使.php文件受到远程回发的影响,而MVC操作不会受到影响?
1 个解决方案
#1
1
The PHP script doesn't have any HTTP Method guards - it would be run in a GET or a POST request, whereas the MVC engine only fires the approved
method in response to a POST request (because you have the [HttpPost]
attribute). I'm guessing you're just hitting your server with your web-browser (which would always fire a GET request) instead of using a tool to create a POST request.
PHP脚本没有任何HTTP方法保护——它将在GET或POST请求中运行,而MVC引擎只在响应POST请求时触发已批准的方法(因为您有[HttpPost]属性)。我猜你只是用web浏览器(它总是会触发GET请求)来访问服务器,而不是使用工具来创建POST请求。
#1
1
The PHP script doesn't have any HTTP Method guards - it would be run in a GET or a POST request, whereas the MVC engine only fires the approved
method in response to a POST request (because you have the [HttpPost]
attribute). I'm guessing you're just hitting your server with your web-browser (which would always fire a GET request) instead of using a tool to create a POST request.
PHP脚本没有任何HTTP方法保护——它将在GET或POST请求中运行,而MVC引擎只在响应POST请求时触发已批准的方法(因为您有[HttpPost]属性)。我猜你只是用web浏览器(它总是会触发GET请求)来访问服务器,而不是使用工具来创建POST请求。