如何用http模块捕获非aspx文件? [英] How to catch non-aspx files with a http module?

查看:127
本文介绍了如何用http模块捕获非aspx文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何做到这一点?



如果我制作一个http模块,它只会捕获.aspx文件。其他扩展名(.js,.htm)的文件被忽略。



这与IIS有什么关系吗?



奇怪的是,所有的扩展都在ASP.net Web Development Server上捕获,但是在IIS中托管时并不是这样。

解决方案

是它与IIS有关。



如果您使用的是IIS7,则会有一个名为集成管道的功能,它将允许IIS站点处理所有传入文件类型为.net,不管它们是.aspx还是不。这对保护非aspx资源特别有用。为了仍然提供静态文件资源,.net运行时首先检查是否存在静态文件,然后在请求的路径中没有找到静态文件资源,它将去寻找处理程序。



如果您在非集成管道模式(经典模式)下使用IIS6(或更早版本)或IIS7,仍然可以拦截对其他扩展的请求,并且您必须配置IIS以发送这些请求文件类型为.net。这被称为应用程序扩展映射。



(PS我真的想为这个答案找到一些很好的链接,但画了一些空白。管道和应用程序扩展映射)。

How to do it?

If I make a http module it only catches .aspx files. Files with other extensions (.js, .htm) are ignored.

Does this have anything to do with IIS?

Strangely enough all extensions are caught on the ASP.net Web Development Server but not when hosted in IIS.

解决方案

Yes it does have something to do with IIS.

If you are using IIS7 there is a feature called "Integrated Pipeline" which will allow an IIS site to pass processing of all incoming files type to .net be they .aspx or not. This is especially useful for securing non-aspx resources. In order to still serve static file resources out of the box the .net runtime checks for the existence of a static file first, it there is none at the requested path it will go looking for a handler.

If you are using IIS6 (or earlier) or IIS7 in non-integrated pipeline mode (classic mode) you can still intercept requests for other extensions, and you'll have to configure IIS to send requests for these file types to .net. This is called "application extension mapping".

(P.S. I really tried to get some good links for this answer, but drew a bit of a blank. Try googling "Integrated Pipeline" and "application extension mapping").

这篇关于如何用http模块捕获非aspx文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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