我是用winform写了一个登陆窗口,当输入账号密码是通过post传入到webbrower中,然后在webbrower中显示账号密码,代码是这样的 private void button1_Click(object sender, EventArgs e)
{
Encoding encoding = Encoding.GetEncoding("utf-8");
string URL = "http://192.168.1.115/cccn/test_post.php";
string postData = "username=" + textBox1.Text.ToString() + "&password=" + textBox2.Text.ToString();
byte[] data = encoding.GetBytes(postData);
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(URL);
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded;charset=utf-8";
myRequest.ContentLength = data.Length;
Stream st = myRequest.GetRequestStream();
st.Write(data, 0, data.Length);
st.Close();
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
Stream receiveStream = myResponse.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream, encoding);
char[] read = new char[256];
int count = readStream.Read(read, 0, 256);
String str = null;
while (count > 0)
{
str += new string(read, 0, count);
count = readStream.Read(read, 0, 256);
}
myResponse.Close();
readStream.Close(); 网页不显示,怎么回事啊c#.net postwebbrower
{
Encoding encoding = Encoding.GetEncoding("utf-8");
string URL = "http://192.168.1.115/cccn/test_post.php";
string postData = "username=" + textBox1.Text.ToString() + "&password=" + textBox2.Text.ToString();
byte[] data = encoding.GetBytes(postData);
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(URL);
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded;charset=utf-8";
myRequest.ContentLength = data.Length;
Stream st = myRequest.GetRequestStream();
st.Write(data, 0, data.Length);
st.Close();
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
Stream receiveStream = myResponse.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream, encoding);
char[] read = new char[256];
int count = readStream.Read(read, 0, 256);
String str = null;
while (count > 0)
{
str += new string(read, 0, count);
count = readStream.Read(read, 0, 256);
}
myResponse.Close();
readStream.Close(); 网页不显示,怎么回事啊c#.net postwebbrower
解决方案 »
- ◆◆◆正则表达式问题◆◆◆
- 关于NumericUpDown的问题
- 用于errorprovider的icon图标哪里有下载?
- 反射问题: 怎么样动态生成一个枚举值Type.InvokeMember方法根本不能实例一个枚举请高手赐教
- ExecuteNonQuery的问题
- QQ客户端之间聊天是才用UDP协议吗?
- WPF,冒泡和隧道
- Winform DataGridView 里面设置了字体的样式,可是每点击一下DataGridView 上的内容,当前单元格的字体颜色就加深,有什么办法解决?
- c# 窗体数据更新
- 求vs.net 2003的教材,2002教材的好多例子不能在2003上调试成功。
- 求C# 夸数据更新数据的sql语句
- InteropServices:如何在C#中声明这个C++函数?
你那个应该是用webbrowser操作js就行了吧