求解,为何我post一直失败
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的时候都会失败