System.Net.NetworkCredential is a password authentication for a password authentication in the FCL. Today I am in a .NET application, use WebRequest requesting a web page, because of the LAN, you must access the webproxy and password credentials through the proxy service equipment, and the webpage appears 407 errors. Its code is approximately as follows:
WebProxy _wpr = new WebProxy ( "http: // isaserver: 2000", true); NetworkCredential _cred = new NetworkCredential (@ "CropDomain / UserName", "Password"); _ wrp.Credentials = _cred; WebRequest _wrq = WebRequest.CreateDefault ( New URI ("Page URL")); _ WRQ.Proxy = _Wrp; WebResponse_Wrp = _wrq.getResponse ();
Repeated tracking, check the user account, password, correct correct, but it is impossible to verify it through the agent. Later, change the second sentence code to: Networkcredential _cred = new networkcredential ("Username", "Password", "cropdomain); KO! The code is successful.
Originally, I wanted to steal a lazy to write the user account directly in the first parameter of the networkcredential constructor. I didn't think that this parameter actually only recognized the username, and I won't analyze the user account containing the domain name. I debugged. One morning.