如何挂钩进入IIS以拦截HTTP请求? [英] How do I hook into IIS for intercepting HTTP Requests?

查看:383
本文介绍了如何挂钩进入IIS以拦截HTTP请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试查找有关如何设置IIS的信息以及基本的这是从IIS实现回调所需的代码。我不想要ASP.NET,MVC等...我只是想了解你如何使用IIS作为Web服务器并挂钩IIS在一个程序集中调用的内容,让你挂钩来自浏览器的请求。



令人讨厌的是,我找不到任何关于如何做到这一点的信息!我查看了NancyFx代码,它似乎涉及到了IHttpAsyncHandler,但是就我所知的那样。

I'm trying to find information on how to set up IIS and what a basic "here's the code needed to implement callbacks from IIS". I don't want ASP.NET, MVC, etc...I just want to learn how you use IIS as a web server and hook into whatever it is that IIS calls in one's assembly that let's you hook into requests coming from the browser.

Annoyingly, I can't find any information on how to do this! I've looked at the NancyFx code, and it seems to involve IHttpAsyncHandler, but that's as far as I've gotten.

推荐答案

发现这个:https://msdn.microsoft.com/en-us/library/vstudio/ ms228090%28v = vs.100%29.aspx [ ^ ]



和async,这个 [ ^ ]



但两者都适用于ASP.NET。令我困惑的是,我认为IIS是服务器,正如谢尔盖指出的那样,我不妨编写自己的服务器,当然我有一篇文章,但我想弄清楚使用IIS的最小方法,没有ASP.NET行李。



Marc
Found this: https://msdn.microsoft.com/en-us/library/vstudio/ms228090%28v=vs.100%29.aspx[^]

and for async, this[^]

but both work with ASP.NET. What confuses me is that I thought IIS was the server, and as Sergey pointed out, I might as well write my own server, which of course I have an article about, but I'm wanting to figure out the minimal approach on using IIS, and without the ASP.NET baggage.

Marc


请参阅我对答案的评论。我相信你所要求的是减少了创建自定义HTTP处理模块的问题。请参阅:

https:/ /msdn.microsoft.com/en-us/library/vstudio/ms227673%28v=vs.100%29.aspx [ ^ ],

http://www.iis.net/learn/develop/runtime -extensibility / develop-iis-modules-and-handlers-with-the-net-framework [ ^ ],

在IIS 7.5中编写Http处理程序和模块 [ ^ ]。



我不知道它是否符合您的想法。它可能不是,如果你的想法背后是简单,如果你想象应该有更直接和简单比使用,比如,ASP.NET。但是你应该考虑HTTP服务器的原理。如果您设计了一个HTTP服务器代码以使其可用,您会怎么做?您可能会以某种基本方式组织Web请求和响应的处理。那是什么?显然,将服务器主机文件系统的某些部分(从特定站点的根设置开始)直接映射到HTTP请求和响应。您可以使用一些可配置的规则(主要基于文件名模式)向HTTP响应添加一些HTTP标头(首先,content-type),然后,在标题之后,将逐字逐句文件内容。



最重要的是什么?服务器端技术:路由,URL重命名,服务器端包含和所有这些脚本引擎。它们都足够独立:根据存储在服务器主机文件系统中的一些工件(资源),它们解释HTTP请求并生成HTTP响应,这在某些方面与我前一段中描述的默认值不同。所以,他们必须是一些模块。 提供单独的HTTP挂钩机制是没有意义的,因为这种机制已经由模块化架构提供。



所以,即使我在这里遗漏了一些东西,并且确实存在这样的单独挂钩机制,我仍然提供了一些不进一步研究的理由。 :-)







我不知道你有一篇关于HTTP服务器的文章创造,但你拥有它的事实应该使我的考虑更加明显。 :-)



-SA
Please see my comment to the answer. I believe what you are asking about is reduced to the problem of creating of a custom HTTP handling module. Please see:
https://msdn.microsoft.com/en-us/library/vstudio/ms227673%28v=vs.100%29.aspx[^],
http://www.iis.net/learn/develop/runtime-extensibility/developing-iis-modules-and-handlers-with-the-net-framework[^],
Writing Http Handlers and Modules in IIS 7.5[^].

I don't know if it fits you idea. It might not, if your idea behind was simplicity, if you imagine that there should be more direct and "simple" was than using, say, ASP.NET. But then you should consider the philosophy of an HTTP server. What would you do if you designed an HTTP server code to make it usable? Probably, you would organize handling of Web requests and responses in some basic way. What is that? Apparently, mapping some part of the server host's file system (starting from the root set up for a particular site) directly to HTTP requests and response. You would add some HTTP headers (first of all, "content-type") to the HTTP response using some configurable rules (mostly based on file name pattern) and then, after the headers, the verbatim file content would follow.

What's on top of it? Server-side technologies: routing, URL renames, server-side includes and all those scripting engines. They all are independent enough: they interpret HTTP requests and generated HTTP responses, according to some artifact (resources) stored in the server's host file system, in some ways different from the default described in my previous paragraph. So, they have to be some modules. It would be pointless to provide a separate HTTP hooking mechanism, because such mechanism is already provided by the modular architecture.

So, even if I'm missing something here and such "separate" hooking mechanism does exist, I still provided some rationale for not looking further. :-)



I did not know that you have an article on HTTP server's creation, but the fact that you have it should make my considerations even more apparent. :-)

—SA


这篇关于如何挂钩进入IIS以拦截HTTP请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆