0
我面臨的問題與不同的域發佈的用戶名和密碼 - 一個成功的提交形式,而其他沒有(表格數據是空的)!兩個域的html代碼是相同的。這裏是示例代碼 - 評論域不發佈:任何幫助非常感謝!C#Expect100Continue頭請求
注意:在nginx的數據發佈成功運行,而其他的Apache不,如果在所有已經得到的東西做服務器
public class CookieAwareWebClient : System.Net.WebClient
{
private System.Net.CookieContainer Cookies = new System.Net.CookieContainer();
protected override System.Net.WebRequest GetWebRequest(Uri address)
{
System.Net.WebRequest request = base.GetWebRequest(address);
if (request is System.Net.HttpWebRequest)
{
var hwr = request as System.Net.HttpWebRequest;
hwr.CookieContainer = Cookies;
}
return request;
}
}
# Main function
NameValueCollection postData = new NameValueCollection();
postData.Add("username", "abcd");
postData.Add("password", "efgh");
var wc = new CookieAwareWebClient();
//string url = "https://abcd.example.com/service/login/";
string url = "https://efgh.example.com/service/login/";
wc.DownloadString(url);
//writer.WriteLine(wc.ResponseHeaders);
Console.WriteLine(wc.ResponseHeaders);
byte[] results = wc.UploadValues(url, postData);
string text = System.Text.Encoding.ASCII.GetString(results);
Console.WriteLine(text);
這個計算器後看看http://stackoverflow.com/questions/5401501/how-to-post-data-to-specific-url-using-webclient-in-c-sharp – MethodMan
燦您嘗試將請求/響應與代理HTTP監視工具(如[Fiddler](http://www.fiddler2.com/))進行比較? – mellamokb
從響應頭文件中,我看到Apache響應中缺少了幾個頭文件。這會是一個問題嗎? 1.連接 2.傳輸編碼 從nginx的服務器的響應是: 連接:保活和傳輸編碼 :分塊 這些都是我通過我的C#程序得到答覆,當我運行curl命令 – Srinivas