Wikis > C# Wiki > HttpWebRequest

System.Net.HttpWebRequest _httpWebRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(_URL);

// Proxy Credentials
System.Net.WebProxy _WebProxy = new System.Net.WebProxy();
_WebProxy.Address = new Uri(_ProxyServer);
_WebProxy.Credentials = new System.Net.NetworkCredential(_ProxyUsername, _ProxyPassword);
_httpWebRequest.Proxy = _WebProxy;

// Network Credentials
_httpWebRequest.Credentials = new System.Net.NetworkCredential(_NetworkUsername, _NetworkPassword);

_httpWebRequest.PreAuthenticate = true;
_httpWebRequest.Timeout = System.Threading.Timeout.Infinite;

System.Net.HttpWebResponse _httpWebReponse = null;
try
{ _httpWebReponse = (System.Net.HttpWebResponse)_httpWebRequest.GetResponse(); }
catch (System.Net.WebException ex)
{ }

System.IO.StreamReader _StreamReader = new System.IO.StreamReader(_httpWebReponse.GetResponseStream());

string _Test = _StreamReader.ReadToEnd();
System.Windows.Forms.MessageBox.Show(_Test);

MSDN Artikel

Category: Tags: