I know the WebClient post runs successfully because the breakpoint is hit in the receiver app and the Forms collection has the value of the input field from the WebClient request from the sender app. (Using Windows 8.1)
This is the call:
using (var client = new WebClient())
{
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
var data = "FirstName=John";
var result = client.UploadString("http://localhost/testform/default.aspx", "POST", data);
Console.WriteLine(result);
}
7 Answers, 1 is accepted

2. The .NET Framework is hardcoded to bypass proxies when making requests to "localhost." The workaround is to use the machine name, or "localhost.fiddler" instead.
Regards,
Eric Lawrence
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Fear not-- thousands of people use Fiddler to capture WebClient traffic every day, so we'll get this working.
If using "localhost.fiddler" results in a DNS failure, that means that your client is not using the proper proxy settings. I assume that you've confirmed that your application is using .NET4 and not an earlier version? Do you have any web.config or app.config files that may be overriding the default machine.config proxy settings?
If you're debugging locally, you can also temporarily debug by simply assigning the WebClient's Proxy property directly.
Regards,
Eric Lawrence
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

proxy.Address = new Uri("http://127.0.0.1:8888");
client.Proxy = proxy;
......
Now I see the WebClient post in Fiddler but the final result is this error: The remote server returned an error: (502) Bad Gateway. I get the same result with or without the machine.config changes.
I'm afraid that I don't know what "the final result is this error" means.
Where do you see that error, and what exactly do you see in Fiddler? If the URL is HTTPS, have you configured Windows to trust the Fiddler Root certificate on a machine-wide basis?
-
In Fiddler’s Tools > Fiddler Options > HTTPS tab, click Export Root Certificate to Desktop.
-
Launch mmc.exe.
-
Click File > Add/Remove Snap-In.
-
Select the Certificates snap-in and press Add.
-
When prompted This snap-in will always manage certificates for: choose Computer Account
-
Click Local Computer, then Finish, then OK.
-
Open the Certificates (Local Computer) node.
-
Right-click the Trusted Root Certificate Authorities folder and choose All Tasks > Import.
-
Choose the file you exported in step #1 and import it.
Regards,
Eric Lawrence
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

I got it working now. It didn't work if localhost or 127.0.0.1 or the machine name were used in WebClient. ipv4.fiddler or localhost.fiddler worked. Thanks for your help.