每次上外网时都得先上学校网站,打开IP控制网关,输入用户名和密码才能联外网,如何编个Windows程序,在其中输入用户名和密码确定后就联外网,请高手指点

解决方案 »

  1.   

    学校网站用的web page等,要么你的windows程序能够知道如何发送http请求等,用你的用户名和密码发送到学校的服务器
      

  2.   

    简单问题复杂化并不好。
    你首先要知道那个web page的表单格式,然后用HttpWebRequest直接发送数据包。
      

  3.   

    表单格式是不是指这个:
    <form  name="ipgwform" action="/ipgw/ipgw.ipgw" method="post">用户名(Username):<input type="text" name="uid" SIZE=16 MAXLENGTH=15><br>密&nbsp;&nbsp;码(Password):<input type="password"  autocomplete="on" name="password" SIZE=16 MAXLENGTH=15>
    从网上找的代码:
    string userID = "uid=" + textBoxUserID.Text;
                string password = "password=" + textBoxPassword.Text;
                string postdata = userID + password;
                ASCIIEncoding encoding = new ASCIIEncoding();
                byte[] data = encoding.GetBytes(postdata);            HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://ipgw.neu.edu.cn/");
                myRequest.Method = "POST";
                myRequest.ContentType = "application/x-www-form-urlencoded";
                myRequest.ContentLength = data.Length;
                Stream newStream = myRequest.GetRequestStream();            // Send the data.   
                newStream.Write(data, 0, data.Length);
                newStream.Close();            // Get response   
                HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
                StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.Default);
                string content = reader.ReadToEnd();
                label1.Text = content;
    运行以后提示:远程服务器返回错误:(405)不允许的方法
    请大家指点一下
      

  4.   

    1 发送的地址应该是 http://ipgw.neu.edu.cn/ipgw/ipgw.ipgw
    2 post的数据格式如下:uid=zhang3&password=12345678,你的显然少了 & 符号
      

  5.   

    一个简单的bat脚本即可解决,我们学校也是这样
    参见我的博客http://www.cnblogs.com/beanfrog/archive/2010/08/09/auto_auth_connect.html@echo offset Username=填上学号
    set Password=填上密码explorer "http://ipgw.neu.edu.cn/ipgw/ipgw.ipgw?uid=%Username%&&password=%Password%&&range=2&&timeout=1&&operation=disconnectall"
    ping -n 2 127.0.0.1 >NUL 2>NUL
    taskkill /im iexplore.exeexplorer "http://ipgw.neu.edu.cn/ipgw/ipgw.ipgw?uid=%Username%&&password=%Password%&&range=2&&timeout=1&&operation=connect"
    ping -n 2 127.0.0.1 >NUL 2>NUL
    taskkill /im iexplore.exe