zoukankan      html  css  js  c++  java
  • C#实现路由器断开连接,更改公网ip

    publicstaticvoid Disconnect()
    {
    string url ="断 线";
        
    string uri ="http://192.168.1.1/userRpm/StatusRpm.htm?Disconnect="+ System.Web.HttpUtility.UrlEncode(url, System.Text.Encoding.GetEncoding("gb2312")) +"&wan=1";
        
    string sUser ="admin";
        
    string sPwd ="admin";
        
    string sDomain ="";
        NetworkCredential oCredential;
        HttpWebRequest oRequest
    = (System.Net.HttpWebRequest)WebRequest.Create(uri);
        
    if (oRequest !=null)
        {
    oRequest.ProtocolVersion
    = HttpVersion.Version11;// send request
            oRequest.Method ="GET";
            oRequest.ContentType
    ="application/x-www-form-urlencoded";
            oRequest.UserAgent
    ="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; GTB6.4; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)";
            oRequest.Referer
    ="http://192.168.1.1";

            
    if (sUser != String.Empty)
            {
    oCredential
    =new NetworkCredential(sUser, sPwd, sDomain);
                 oRequest.Credentials
    = oCredential.GetCredential(new Uri(uri), String.Empty);
            }
            
    else
            {
                 oRequest.Credentials
    = CredentialCache.DefaultCredentials;
            }
            StreamReader sr
    =new StreamReader(oRequest.GetResponse().GetResponseStream(), System.Text.Encoding.Default);
            
    string line = sr.ReadToEnd();
            sr.Close();
            
    if (line.IndexOf("LAN口状态") >-1)//登录成功
            {
                 Console.WriteLine(
    "断开登录成功");
            }
            
    else
            {
                Console.WriteLine(
    "断开登录失败");
            }
        }
    }
  • 相关阅读:
    yii 验证码功能的实现
    关于php优化 你必须知道的一些事情
    php实现两分法查找
    Python封装的访问MySQL数据库的类及DEMO
    新学习的Python的代码(while循环)
    基于位运算符的IP和数值转换
    JS数组操作常用方法
    JS输出日历
    PHP程序输出日历
    PHP中计算时间差(上周,上月,去年,昨天等)
  • 原文地址:https://www.cnblogs.com/goody9807/p/3526153.html
Copyright © 2011-2022 走看看