HighTechTalks DotNet Forums  

HttpWebRequest/Reponse and VPN

Dotnet Framework (SDK) microsoft.public.dotnet.framework.sdk


Discuss HttpWebRequest/Reponse and VPN in the Dotnet Framework (SDK) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Naresh Mirkhelkar
 
Posts: n/a

Default HttpWebRequest/Reponse and VPN - 03-21-2006 , 03:41 PM






Hi,
I am working on a kind of a "stand alone" m\c where in i have to connect
using VPN to get into our company's network.
I created a webpage on my local machine (WinXP) and was trying to use
HttpWebRequest/HttpWebResponse object to read other site feeds. However, i am
always getting "Underlying connection is closed" or "operation timed out"
errors. The same code works fine if i call any Localhost URL, but not working
as expected for internet URLs.

My doubt here is, if IE is able to access any site, why can't i don the same
with my code.

I have tried to create a WebProxy as well (though my IE is not using any
proxy to connect to internet) by providing the VPN's IP. It did not work. Can
someone please let me know what is wrong with the below code.

HttpWebRequest rssReq = (HttpWebRequest)HttpWebRequest.Create(new
Uri("http://www.quotationspage.com/data/mqotd.rss"));
rssReq.Method="GET";
rssReq.UserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
..NET CLR 1.1.4322)";
//rssReq.Headers.Add("Translate","t");
rssReq.Timeout = 30000;
rssReq.ContentType="text/xml";
rssReq.ProtocolVersion=HttpVersion.Version10;
WebProxy webprox=new WebProxy("xx.xxx.xxx.xx");
//rssReq.Proxy = System.Net.WebProxy.GetDefaultProxy();

NetworkCredential nc=new
NetworkCredential("naresh.mirkhelkar","pwd","domai n");
System.Net.CredentialCache SuperUserCredentials = new
System.Net.CredentialCache();
SuperUserCredentials.Add( new
System.Uri("http://www.quotationspage.com/data/mqotd.rss"),
"NTLM",
new System.Net.NetworkCredential("naresh.mirkhelkar"," pwd","domain")
);
webprox.Credentials = SuperUserCredentials;
rssReq.Proxy = webprox;
//rssReq.Credentials = SuperUserCredentials;
rssReq.Credentials = nc;
rssReq.KeepAlive = false;
//-------FAILING HERE------------
HttpWebResponse response = (HttpWebResponse)rssReq.GetResponse();
//Get the Response Stream from the URL
Stream responseStream = response.GetResponseStream();
-----

Note: Please let me know or redirect this mail to the right alias if this is
not the right one for such issues.
Thanks,
Naresh






Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.