求解,为何我post一直失败

Hosea_Cube 2017-01-07 02:05:53
namespace Blossom
{
public partial class LoginForm : Form
{
public LoginForm()
{
InitializeComponent();
}

private void LoginButton_Click(object sender, EventArgs e)
{
string param = "username=" + HttpUtility.UrlEncode(UsernameBox.Text, Encoding.UTF8) + "&password=" + PasswordBox.Text + "&coin=5&auther=%e5%8c%97%e8%a9%a9&language=zh-cn";
byte[] parambytes = Encoding.ASCII.GetBytes(param);
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://2pta.org/dev/check.php");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = parambytes.Length;
req.KeepAlive = true;
using (Stream stream=req.GetRequestStream())
{
stream.Write(parambytes, 0, parambytes.Length);
}
HttpWebResponse responsble = (HttpWebResponse)req.GetResponse();
using (StreamReader reader = new StreamReader(responsble.GetResponseStream()))
{
MessageBox.Show(reader.ReadToEnd());
}


}
}
}




代码是这样的,请问哪里写错了么
每次在获取response的时候都会失败
...全文
696 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xisuo67 2017-01-11
  • 打赏
  • 举报
回复
此贴通过C#HttpWebRequest测试回复
  • 打赏
  • 举报
回复
try catch,就算有异常应该也是有返回的,除非是超时,才没任何响应
蝶恋花雨 2017-01-09
  • 打赏
  • 举报
回复
引用 2 楼 Oseaaa 的回复:
好吧,这个怎么检测?
php这里你是怎么处理的参数的?把这些参数输出看看。
Hosea_Cube 2017-01-07
  • 打赏
  • 举报
回复
引用 1 楼 kongwei521 的回复:
检查下 check.php得到的post参数
这个连response都获取不到
Hosea_Cube 2017-01-07
  • 打赏
  • 举报
回复
引用 1 楼 kongwei521 的回复:
检查下 check.php得到的post参数
好吧,这个怎么检测?
蝶恋花雨 2017-01-07
  • 打赏
  • 举报
回复
检查下 check.php得到的post参数

17,741

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧