【发布时间】:2013-03-05 07:27:20
【问题描述】:
我在 Windows 上有一个 wamp 服务器。 SSL 配置正确。在浏览器中,它正在工作抛出 https: 。我有一个脚本 test.php,我想下载一些 POST 数据并将其上传到它。我有我的 C# 代码:
WebClient client = new WebClient();
client.Encoding = Encoding.UTF8;
NameValueCollection values = new NameValueCollection();
values.Add("paramtest", "testval");
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
byte[] result;
result = client.UploadValues("https://127.0.0.1./test.php", "POST", values);
string htmlCode = Encoding.UTF8.GetString(result);
textBox1.Text = htmlCode;
当使用 http 运行此代码时,我得到了所有数据。放 https 时,服务器报错:
400 错误请求
错误请求
您的浏览器发送了此服务器无法发送的请求 明白。
你知道我该如何解决它吗?
【问题讨论】: