如何捕获 URL 或 HTTP 请求并使用 C# 重定向它
大家好,感谢您的阅读。
对于 QA 方式,我想设置一个应用程序,可以处理和管理特定运行应用程序通过互联网发送的请求和数据。
更具体地说,我希望能够重定向几个网址,而不是每个网址,以通过“代理应用程序”工作,因此,如果我有一个请求 http://www.google.com 和 http://www.google .com/search,我只想重定向第二个指向相对路径 /search 的路径。
我希望你能明白。 你们有什么简单实现的想法以及可能有一个现有的框架来实现这一点吗?如果您至少给我一些带有示例的代码,我将不胜感激。
提前致谢。
更新:事实上,我需要构建一个应用程序,该应用程序可以以某种方式“附加”到并劫持已开发的应用程序和数据服务器之间的现有连接,以便它可以侦听和修改通过这个连接。我知道用 C# 这样的高级语言很难完成,但我只是想确保
Hello everyone and thanks for reading.
For means of QA, I want to setup an application that could handle and manage the requests and the data sent through the internet from an especific running application.
More specifically, I want to be able to redirect a few urls, not every one, to work via a "proxy application", so if I have an application that requests http://www.google.com AND http://www.google.com/search, I would want to redirect only the second one poiting to the relative path /search.
I hope you get the idea.
Do you guys have any ideas for an easy implementation and maybe an existing framework to accomplish that? I would be thankful if you give me at least some piece of code with an example.
Thanks in advance.
Update: In fact, I needed to build an application that could somehow be "attached" to and hijack an existing connection between the already developed application and the data server so it could listen and modify the data sent through this connection. I know its hard to accomplish in a high level language like c# but I just wanted to make sure
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定我是否正确理解了您的意思...您想将某些 URL 重定向到“代理应用程序”???不是代理服务器?
如果你想重定向到代理服务器,那么你可以这样做:
或者没有代理服务器:
你可以让“代理应用程序”提供 URL,但这是一个完全不同的故事。在这种情况下,您将需要在您的应用程序和其他应用程序之间进行某种通信方法。您的应用可以通过 TCP、通过 WCF 或通过管道。您将 URL 发送到其他应用程序,它会为其提供服务。
然后是另一部分:代理应用程序是否将页面返回给请求处理应用程序,还是将其提供给客户端?那么客户端如何与您的请求处理应用程序进行通信呢?
更新
听起来您正在寻找类似 Fiddler 的东西:
一般来说,您可能需要研究流量拦截。
I'm not sure I follow you correctly... you want to redirect certain URLs to a "proxy application"??? Not a proxy server?
If you want to redirect to a proxy server then you can do this:
Or without a proxy server:
You can let a "proxy application" serve the url, but that's a completely different story. In that case you will need some method of communication between your application and the other application. Your app can connect to the other app via TCP, via WCF or via Pipes. You send the URL to the other application and it serves it.
Then comes the other piece: does the proxy application serve the page back to your request handling application or does it serve it to the client? So how is the client communicating with your request handling application?
Update
It sounds like you're looking for something like Fiddler:
In general you might want to look into traffic interception.