[英]POST don't work
所有! 我有這樣的PHP頁面:
<?php
if(isset($_POST['userid']) and isset($_POST['dlspeed']) )
{
$userid=$_POST['userid'];
$dlspeed=$_POST['dlspeed'];
$timestamp =date("y-m-d H:i");
$db_conn = mysql_connect('localhost', "root", "asdk78623r");
mysql_select_db("speedtest", $db_conn);
$query='INSERT INTO status VALUE (NULL, "'.$userid.'", "'.$dlspeed.'", "'.$timestamp.'")';
$result=mysql_query($query,$db_conn);
}
?
從C#中我發布:
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(pageurl);
byte[] buffer = Encoding.ASCII.GetBytes(data);
System.Net.ServicePointManager.Expect100Continue = false;
WebReq.SendChunked = false;
WebReq.Expect = null;
WebReq.KeepAlive = false;
//I try also setting proxy
// WebReq.Proxy = new WebProxy("192.168.0.107", 3128);
//Our method is post, otherwise the buffer (postvars) would be useless
WebReq.Method = "POST";
//We use form contentType, for the postvars.
WebReq.ContentType = "application/x-www-form-urlencoded";
//The length of the buffer (postvars) is used as contentlength.
WebReq.ContentLength = buffer.Length;
//We open a stream for writing the postvars
Stream PostData = WebReq.GetRequestStream();
//Now we write, and afterwards, we close. Closing is always important!
PostData.Write(buffer, 0, buffer.Length);
PostData.Close();
//posted data is not inserted in db
//and in follow line code Ive got error: The remote server returned an error: (417) //Expectation failed
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
我做錯了什么? 使用Follow curl命令可以正常工作:
curl -d "userid=SW783IC2QDHFYU6P4XKO&dlspeed=814,602968463903×tamp=2012-2-23 19:29:33" pageurl
有什么想法,建議,重新考慮嗎?
有多種選擇可能會導致這種情況發生。
http://www.checkupdown.com/status/E417.html
原因之一可能是: http : //haacked.com/archive/2004/05/15/http-web-request-expect-100-continue.aspx
安裝一個程序來記錄您的請求及其所包含的內容(fiddler2很好用,是免費且易於使用的,有幾個非常相似,但記不得它們的名稱是atm)
嘗試查看是否找到了不應該存在的標頭,如果您一生都無法找到它,請在發帖后找到這里的人可能會幫助您。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.