views:

163

answers:

2

Hi,

I'm trying to get HTTP calls I'm making from C# .NET to a local address (localhost:3000) to use the proxy I set (so I can go through fiddler). Using the below WebProxy approach works if I point the target URL to a non-local address, however I need to point it to a local web-server I have (at localhost:3000), and when I do this the request is not going through the proxy.

I have inlcuded the "proxyObject.BypassProxyOnLocal = false". This should make it work no? Any suggestions re how to force the request to go through the WebProxy for http calls targetting a local address?

    WebProxy proxyObject = new WebProxy("http://localhost:8888/", false);
    proxyObject.Credentials = new NetworkCredential(); 
    proxyObject.BypassProxyOnLocal = false;
    WebRequest.DefaultWebProxy = proxyObject;

    var request = (HttpWebRequest)WebRequest.Create(targetUri);

    // I also included this line as a double check
    request.Proxy = proxyObject;

Subsequent calls do not go through the proxy however, such as when I do:

 var res = (HttpWebResponse)req.GetResponse();

thanks

A: 

Try getting a log of this session (see http://ferozedaud.blogspot.com/2009/08/tracing-with-systemnet.html). And the log should show why the proxy is not being selected.

feroze
A: 

someone pointed out to me I'd forgot to assign the newly created instance to myDataset

if(myDataSet == null)
{
    myDataSet = new MyDataSet();
}
return myDataSet

thanks

Greg