Is there any way in .NET to programmatically listen to HTTP traffic?

落花浮王杯 提交于 2019-11-29 16:10:59

Try winpcap . It's a driver/library combination which can be used to monitor packets. Based on what you are trying to do (watch traffic w/o a UI), this is probably a simpler solution than writing your own proxy.

You probably don't want to proxy, that will introduce a lot of unnecessary complexity.

Consider packet sniffing instead, which is pretty much a solved problem. Wireshark is handy as a stand alone utility you can use manually, but it's also possible to do packet sniffing programmatically, using WinPcap, the library on which Wireshark is based. Here's a couple of examples of WinPcap in .Net, .NetNomad's example with sample project, and a CodeProject tutorial, also with source.

There are numerous apps for this. My recommendation is Wireshark

SaaS Developer

Have you looked at implementing an Http Module or an Http Handler (.ashx)? They will allow you to intercept each and every web request and process them as you need before getting to your page.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!