Proxy Credentials for web requests

TO make WebRequests from behind a firewall, we need to attach a proxy object to our request.

    
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
//Create proxy credentials
ICredentials credential = new NetworkCredential(uid, password, domain);
//Create proxy server. byPassListArray is a string array of local ip's to bypass
IWebProxy proxyServer = new WebProxy(proxy,true,byPassListArray,credential);

request.Proxy = proxyServer;
request.Credentials = new NetworkCredential(Uid,Password);

example code snippet:

string query="http://www.feedster.com/search.php?type=rss&q=" +srch+ "&sort=date&limit=100";
WebProxy proxyObj = new WebProxy("10.10.249.19", 8080) ;
NetworkCredential networkCredential = new NetworkCredential("yourname", "yourpass") ;
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(query) ;
proxyObj.Credentials = networkCredential ;
req.Proxy = proxyObj ;
// this request uses the default credential set--
req.Credentials = System.Net.CredentialCache.DefaultCredentials ;
// or we can create unique new credentials:
//request.Credentials = new NetworkCredential(Uid,Password);

XmlDocument doc = new XmlDocument();
System.Net.HttpWebResponse resp =(HttpWebResponse)req.GetResponse() ;
doc.Load(resp.GetResponseStream());
XmlDocumentFragment frag = doc.CreateDocumentFragment();
XmlNode nod=doc.SelectSingleNode("//channel/item");