Problem with Proxies and HttpRequests

A

Andrew Weir

Hello there,

I'm having a bit of trouble writing a program that reads an XML file
located on a webserver. I've had a go myself to try and code it but I'm
getting a strange error.

HttpWebRequest myWebRequest =
(HttpWebRequest)WebRequest.Create("http://webServer.com/");
WebProxy myWebProxy = new WebProxy("10.0.0.2");
NetworkCredential myCred = new NetworkCredential("user", "pass",
"domain.local");
myWebRequest.Proxy = myWebProxy;
myWebRequest.Proxy.Credentials = myCred;
HttpWebResponse myWebResponse =
(HttpWebResponse)myWebRequest.GetResponse();

// outputs the status of the http response.
Console.WriteLine(myWebResponse.StatusDescription);

If myWebRequest =
(HttpWebRequest)WebRequest.Create("http://webServer.com/"), everything
is fine and the myWebResponse is OK.

If mywebRequest =
(HttpWebRequest)WebRequest.Create("http://webServer.com/myfile.xml"),
then I have to process through an exception where it says remote server
(404) File not found.

The file is there however.

Suggestions?

Regards,
Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top