我可以用什么代替@?
What can I use instead of @?
我申请毕业设计。总结,我需要将 "bodyBefore" 变量写成类似于 "body" 变量。我没法翻译。
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost/server/login.php");
//request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0";
//request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
//request.Headers.Set(HttpRequestHeader.AcceptLanguage, "tr-TR,tr;q=0.8,en-US;q=0.5,en;q=0.3");
//request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request.Referer = "http://localhost/server/index.html";
request.KeepAlive = true;
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
request.ServicePoint.Expect100Continue = false;
string bodyBefore = frm1.txtUserInput.Text+"="+frm1.txtUsername.Text+"&"+frm1.txtPassInput.Text+"="+frm1.txtPassword.Text+"&"+"submit=Login";
//string body = @bodyBefore;
string body = @"username=admin&password=12345&submit=Login";
MessageBox.Show("Body before : " + bodyBefore+"\nBody"+body);
byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(body);
request.ContentLength = postBytes.Length;
Stream stream = request.GetRequestStream();
stream.Write(postBytes, 0, postBytes.Length);
stream.Close();
body 和 bodyBefore 字符串没有区别:
变量期望:
txtUsername : Textbox of username ///
txtPassword : Textbox of password ///
txtUserInput : Textbox of username input name in web page ///
txtPassInput : Textbox of password input name in web page
问题已解决。当我如下编辑 "body" 变量时,它起作用了。
string body = string.Format("{0}={1}&{2}={3}&submit=Login", frm1.txtUserInput.Text, frm1.txtUsername.Text, frm1.txtPassInput.Text, frm1.txtPassword.Text);
感谢您的帮助。
我申请毕业设计。总结,我需要将 "bodyBefore" 变量写成类似于 "body" 变量。我没法翻译。
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost/server/login.php");
//request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0";
//request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
//request.Headers.Set(HttpRequestHeader.AcceptLanguage, "tr-TR,tr;q=0.8,en-US;q=0.5,en;q=0.3");
//request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request.Referer = "http://localhost/server/index.html";
request.KeepAlive = true;
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
request.ServicePoint.Expect100Continue = false;
string bodyBefore = frm1.txtUserInput.Text+"="+frm1.txtUsername.Text+"&"+frm1.txtPassInput.Text+"="+frm1.txtPassword.Text+"&"+"submit=Login";
//string body = @bodyBefore;
string body = @"username=admin&password=12345&submit=Login";
MessageBox.Show("Body before : " + bodyBefore+"\nBody"+body);
byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(body);
request.ContentLength = postBytes.Length;
Stream stream = request.GetRequestStream();
stream.Write(postBytes, 0, postBytes.Length);
stream.Close();
body 和 bodyBefore 字符串没有区别:
变量期望:
txtUsername : Textbox of username ///
txtPassword : Textbox of password ///
txtUserInput : Textbox of username input name in web page ///
txtPassInput : Textbox of password input name in web page
问题已解决。当我如下编辑 "body" 变量时,它起作用了。
string body = string.Format("{0}={1}&{2}={3}&submit=Login", frm1.txtUserInput.Text, frm1.txtUsername.Text, frm1.txtPassInput.Text, frm1.txtPassword.Text);
感谢您的帮助。