Question

I want to watch all the HTTP requests going out of a certain application and cancel them if needed.

Is there a way to do this in C#?

Was it helpful?

Solution

If you can touch the system's proxy configuration (which is used by many applications) or, if the app doesn't heed that setting, touch the application's configuration to use a proxy of your choice, you can create a HTTP proxy that would do the job for you.

If you just want to profile, there is a ready made tool that behaves like this and is very nice, Fiddler.

Else you'd have to go deeper into the network stack and implement something like a sniffer/firewall, for instance using WinPcap. That's a lot harder to do.

OTHER TIPS

If you're working with Windows, it is possible to hook the WinInet API calls and do whatever you want with them.

FreeCap (or its commercial version, WideCap) does that: allows you to send TCP traffic through a proxy server. That proxy might then do the filtering (e.g. Fiddler).

I know this brings more stand-alone applications into the system, but it works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top