从窗口服务调用时代码中的问题. [英] problem in code when calling from window service....

查看:121
本文介绍了从窗口服务调用时代码中的问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从Window应用程序调用以下代码时,它运行正常,
并通过我的系统访问该网址..
但是当我通过WINDOW服务调用相同的代码时,我遇到了问题.它给我错误无法连接到远程服务器"
System.Net.WebException:
无法连接到远程服务器---> System.Net.Sockets.SocketException:无法建立连接,因为目标计算机主动拒绝了它24.136.198.105


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


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...

推荐答案

您可能想尝试在创建的请求对象上指定代理服务器,可能未在该服务正在使用的用户帐户,请查看 system.net.httpwebrequest.proxy [^ ]了解更多信息.另外,添加网络凭据也将是有益的.

祝你好运
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


这篇关于从窗口服务调用时代码中的问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆