c#winform打开网页并post数据到要打开的网页 在winform里面点击按钮,将winform里的用户名密码通过post的方法传递给要一个网页,并使用浏览器打开此网页,应该怎么实现啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 使用webbroswer拼接诶字符串 webbroswer1.Navigate("http://"); post ?这个真要依照不同的网站去具体看,简单点的就是网址后面拼接查询字符串 http://www.example.com?uid=XXX 之类的麻烦点就要自己设置cookies.net里面有个封装好的类,叫HttpRequest(名字大概如此)的类,挺有用的 HttpRequest不行啊,不能打开浏览器啊webbroswer1.Navigate("http://");这个不是显示在webbroswer里了吗,我需要显示在浏览器里 http://www.cnblogs.com/coolhao-chen/archive/2009/09/07/1562087.html这个是你想要的 public static void OpenNewIe(string url, string postData) { var ie = new InternetExplorer(); object vPost, vHeaders, vFlags, vTargetFrame; vPost = null; vFlags = null; vTargetFrame = null; vHeaders = "Content-Type: application/x-www-form-urlencoded" + Convert.ToChar(10) + Convert.ToChar(13); if (!string.IsNullOrEmpty(postData)) vPost = ASCIIEncoding.ASCII.GetBytes(postData); ie.Visible = true; ie.Navigate(url, ref vFlags, ref vTargetFrame, ref vPost, ref vHeaders); }我帮你贴代码才是现实的,懒得让你看 请添加 COM 下 的microsoft internet controls 引用. System.Windows.Forms.HtmlDocument HTMLDocument = wbHistorySearch.Document; System.Windows.Forms.HtmlElement loginName= HTMLDocument.GetElementById("loginName"); loginName.InnerText = System.Configuration.ConfigurationSettings.AppSettings["LoginName"].ToString(); //loginName.Enabled = false; System.Windows.Forms.HtmlElement password = HTMLDocument.GetElementById("passwd"); password.InnerText = System.Configuration.ConfigurationSettings.AppSettings["Password"].ToString(); //password.Enabled = false; System.Windows.Forms.HtmlElement btnLogin = HTMLDocument.GetElementById("login"); btnLogin.InvokeMember("click"); btnLogin.Enabled = false; System.Windows.Forms.HtmlElement btnReset = HTMLDocument.GetElementById("Submit2"); 都不起作用的,post过去的数据得看你访问的网页是Session保存的数据还是静态变量。Session你改了也只是在服务器上,客户端请求完成之后客户端是没法加载服务器的Session这应该能理解吧? C# 两个bitmap类型变量的赋值出错 vs2010开发的程序无法在win8上运行 拿到winform源码后应该怎样学习? C# 事件委托问题? 朋友,当你闲暇时,不妨玩玩这个翻牌游戏 序列化字段不输出问题 从数据库中得到一个日期的字符串,如何能格式化它?? vs2008通过odbc连接sybase 15.2报错! 请教:方法未获取"1"的参数 C#如何判断多线程都已经结束?多线程执行完成所用的时间? 怎样调用windows mobile下的功能项 OutLookBar 控件 右键问题
webbroswer1.Navigate("http://");
这个真要依照不同的网站去具体看,
简单点的就是网址后面拼接查询字符串 http://www.example.com?uid=XXX 之类的
麻烦点就要自己设置cookies.net里面有个封装好的类,叫HttpRequest(名字大概如此)的类,挺有用的
webbroswer1.Navigate("http://");
这个不是显示在webbroswer里了吗,我需要显示在浏览器里
{
var ie = new InternetExplorer();
object vPost, vHeaders, vFlags, vTargetFrame;
vPost = null;
vFlags = null;
vTargetFrame = null;
vHeaders = "Content-Type: application/x-www-form-urlencoded" + Convert.ToChar(10) + Convert.ToChar(13);
if (!string.IsNullOrEmpty(postData))
vPost = ASCIIEncoding.ASCII.GetBytes(postData);
ie.Visible = true;
ie.Navigate(url, ref vFlags, ref vTargetFrame, ref vPost, ref vHeaders);
}
我帮你贴代码才是现实的,懒得让你看
System.Windows.Forms.HtmlElement loginName= HTMLDocument.GetElementById("loginName");
loginName.InnerText = System.Configuration.ConfigurationSettings.AppSettings["LoginName"].ToString();
//loginName.Enabled = false;
System.Windows.Forms.HtmlElement password = HTMLDocument.GetElementById("passwd");
password.InnerText = System.Configuration.ConfigurationSettings.AppSettings["Password"].ToString();
//password.Enabled = false;
System.Windows.Forms.HtmlElement btnLogin = HTMLDocument.GetElementById("login");
btnLogin.InvokeMember("click");
btnLogin.Enabled = false;
System.Windows.Forms.HtmlElement btnReset = HTMLDocument.GetElementById("Submit2");