我有一个从 POST 请求中获得响应的代码:
//Запрос авторизации бухаря
WebRequest request = WebRequest.Create("http://clannr.org/scripts/login/auth.php");
request.Method = "POST";
string postData = "user=" + Login.Text + "&password=" + Password.Text + "&version=13";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
reader.Close();
dataStream.Close();
response.Close();
但是在检查响应时:
Match match = regex.Match(responseFromServer);
if (match.Success)
{
var input = responseFromServer;
var split = input.Split(':');
var final = split[3];
ProcessStartInfo mcStartInfo = new ProcessStartInfo("javaw", "-Xms1024m -Xmx1024m -cp \"" + appData + "\\.ClanNR\\bin\\minecraft1.jar;" + appData + "\\.ClanNR\\bin\\jinput.jar;" + appData + "\\.ClanNR\\bin\\lwjgl.jar;" + appData + "\\.ClanNR\\bin\\lwjgl_util.jar \" -Djava.library.path=\"" + appData + "\\.ClanNR\\bin\\natives\" net.minecraft.client.Minecraft" + " " + username + " " + final + " " + server1);
Process.Start(mcStartInfo);
this.Close();
}
else if (responseFromServer == " Bad Login")
{
MessageBox.Show("Uncorrect login/password!");
}
else if (responseFromServer == " Old version")
{
MessageBox.Show("Launcher is old!");
}
我的代码只调用了 2 个函数,即 show 2 MessageBox
如何解决?
更新