Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
When i call this following code from Window application it runs fine,
and also the url is accessed through my system..
but i have problem when i call this same code through WINDOW serviece. it gives me error that 'Unable to connect to the remote server'
System.Net.WebException:
Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 24.136.198.105


C#
string url="http://www.abc.com"
 HttpWebRequest wReq;
         
 wReq = (HttpWebRequest)WebRequest.Create(url);
 wReq.Method = "GET";
 wReq.AllowAutoRedirect = true;
 wReq.CookieContainer = cc;
 WebResponse wRes = (HttpWebResponse)wReq.GetResponse();


kindly give me the suggestions...
Posted
Updated 3-Nov-11 7:58am
v2
Comments
Mark Salsbery 3-Nov-11 13:51pm    
Is your service application running under a user account that allows network access?
KashifAbbasi786 3-Nov-11 13:58pm    
no my service is not running under user account
Tim Groven 3-Nov-11 14:01pm    
It needs to run under a NetworkAccount then, so it can have access to the network.

1 solution

You might want to try specifying the proxy server on the request object you've created this might not be set under the user account that the service is using so look at system.net.httpwebrequest.proxy[^] for more info. Also adding network credentials will be beneficial as well.

Good luck
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900