HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("https://www.example.com");
NetworkCredential nc = new NetworkCredential("myname", "mypass");
WebProxy myproxy = new WebProxy("192.168.1.1:8080", false);
myHttpWebRequest.Proxy = myproxy;
myHttpWebRequest.Proxy = WebRequest.DefaultWebProxy;
myHttpWebRequest.Method = "GET";
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
MessageBox.Show("Ok");
我正在使用此代碼與網站(C#.net桌面應用程序)連接。但我有這個錯誤信息:代理身份驗證錯誤
The remote server returned an error: (407) Proxy Authentication Required.
我該如何解決這個問題?
您是否需要將nc傳遞給WebProxy構造函數? – spb