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 errorError 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;
}
Please help to solve this error
rgds
解决方案Dear Friend,
Either the credentials you are providing are incorrect or Check with your firewall expert. They open the firewall for PROD servers so there is no need to use the Proxy.
OR
You have to set the Credentials in two locations to get past the 407 error:
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
Check if this thread on StackOverFlow is of any help.
407 proxy authentication required[^]
when i remove domain name from networkwork credentaial it works