Reputation: 1
I'm developing an application (in C#) which sends http requests. Everything works fine as long as there's no Proxy with authentication involved.
Here's my code:
request = (HttpWebRequest) WebRequest.Create(uri);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = length;
request.Proxy.Credentials = new NetworkCredential("hans", "maulwurf");
request.Credentials = new NetworkCredential("hans", "maulwurf");
using (var requestStream = request.GetRequestStream())
{
// now send it
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Flush();
requestStream.Close();
}
WebResponse webResponse = request.GetResponse();
On the last line i always get 407. The credentials work in ie/ff.
Does anyone have suggestions what the problem might be? Any help is greatly appreciated!
Upvotes: 0
Views: 1520
Reputation: 14672
I think you may need to also specify the proxy server. like this, for example,
IWebProxy proxy = new WebProxy("<Server IP>", <Server Port>);
proxy.Credentials = new NetworkCredential("hans", "maulwurf");
request.Proxy = proxy;
Upvotes: 1