本文介绍了C#中的Web服务应用程序-的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在使用C#应用程序通过Web服务发送SMS.在我的代码执行期间,当控制权到达尝试catch块的时候,即req.GetResponse(),我收到一个错误

Hello,

I am using my C# application to send SMS through web service. During the execution of my code, when control reaches to try catch block,that is req.GetResponse() i am getting an error

Error is - "The remote server returned an error:(407)Proxy authentication required"


我写的代码是


The code what i have written is

string url = "valid url";

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);

NetworkCredential netcredit = new NetworkCredential("username",    "password", "domain");

req.Credentials = netcredit;

System.Net.WebProxy pry = new WebProxy("192.168.1.4:1598", true);

pry.Credentials = netcredit;

req.Proxy = pry;

req.Method = "HEAD";

try
{
    HttpWebResponse res = (HttpWebResponse)req.GetResponse();
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
    return;
}


请帮助解决此错误

rgds


Please help to solve this error

rgds

推荐答案

HttpWebRequest webRequest = WebRequest.Create(uirTradeStream) as HttpWebRequest;
webRequest.Proxy = WebRequest.DefaultWebProxy;
webRequest.Credentials = new NetworkCredential("user", "password", "domain");
webRequest.Proxy.Credentials = new NetworkCredential("user", "password", "domain")



如果以上方法均无法解决,请点击链接

[ ^ ]

如果可以帮助您,请别忘了将此标记为您的答案.

谢谢



If the above things don''t work out then follow the link

http://blogs.msdn.com/b/jpsanders/archive/2009/03/24/httpwebrequest-webexcepton-the-remote-server-returned-an-error-407-proxy-authentication-required.aspx[^]

Don''t forget to mark this as your answer if it helps you out.

Thanks




这篇关于C#中的Web服务应用程序-的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 04:00