tags:

views:

271

answers:

2

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#?

+7  A: 

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.

Vinko Vrsalovic
+3  A: 

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.

Piskvor