Uri uri = new Uri("http://192.168.1.1/userRpm/StatusRpm.htm?Disconnect=断 线&wan=1");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
var cache = new CredentialCache();
cache.Add(uri, "Basic", new NetworkCredential("admin", "admin"));
request.Credentials = cache;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader read = new StreamReader(response.GetResponseStream(), Encoding.Default);
string text = read.ReadToEnd();
如果你想用程序读取路由器里面的配置,或者用程序断线拨号,那么首先需要登录路由器,登录路由器都需要密码,这个密码如何设置呢,秘密就在上面的代码里面。比如httpwebrequest 401错误,一般就是需要输入密码的。