BUG:IIS7托管请求 [英] BUG: IIS7 managed requests

查看:167
本文介绍了BUG:IIS7托管请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IIS7中,我不知道是否应该将此问题发布到ServerFault,我们可以通过以下方式告诉模块运行托管内容(从而加速静态内容服务):

In IIS7 we can tell a module to run for managed content (thus speeding up static content serving) by:

<modules>
    ...
    <add name="WhateverName"
         type="WhateverType"
         preCondition="managedHandler"
    ...
</modules>

但是。这工作正常和dandy只要在所请求的URL中还有一个文件名(带扩展名)。如果省略它,IIS7会认为你想要静态内容和托管模块不会运行。

But. This works fine and dandy as long as there's also a file name (with extension) in the requested URL. If it's omitted it IIS7 will think you want static content and managed modules won't run.

http://localhost/ <-- this one will skip managed handlers
http://localhost/default.aspx <-- this one will run them



如果我手动设置IIS7默认文档,所以第一个是 default.aspx 我可以看到没有区别没有区别。对我来说,这个看起来,走路和声音像一个错误。 这是一个错误!为什么?因为当我请求第一个,它是一个托管请求,不是它。当然如此。但IIS7将其视为静态请求。所以? 这是一个错误

If I manually set IIS7 default document, so the first one is default.aspx, I can see no difference there's no difference. To me this looks, walks and sounds like a bug. And it is a bug! Why? Because when I request for the first one, it is a managed request, isn't it. Of course it is. But IIS7 treats it as a static request. So? It's a bug. This request should be treated as managed.

如何说服IIS7为没有文件名的网址请求运行托管处理程序?

让我帮助你一点思考:如果我重新排序 system.webServer / handlers ,我相信可以解决这个问题。在指向 StaticFileModule DefaultDocumentModule 的最后 StaticFile DirectoryBrowsingModule 我应该运行集成asp.net处理程序的目录请求。或者编写我自己的处理程序,这将附加默认文档到任何目录请求。我确信其中的一个应该解决它。但是我该如何配置/开发呢?

Let me help you a bit with thinking: If I'd reorder system.webServer/handlers, I'm sure could solve this. Before the last StaticFile handler that points to StaticFileModule, DefaultDocumentModule and DirectoryBrowsingModule I should be running integrated asp.net handler on Directory requests. Or write my own handler, that would append default document to any directory request. I'm pretty sure one of these should solve it. But how would I have to configure/develop it?

推荐答案

问题出在请求处理顺序。 IIS7按照IIS的Handlers配置元素指定的顺序处理请求。默认情况下IIS配置的Handlers元素包含

The problem is in request-processing order. IIS7 processes requests in order specified by Handlers configuration element of IIS. By default Handlers element of the IIS configuration contains

<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />

。因此,所有与之前指定的处理程序不匹配的请求都将由此处理程序处理(包括文件夹请求)。

at the end of the handlers. Therefore all request that not match any previously specified handler, will be processed by this handler (including folder request too).

您可以使用处理程序配置中的清除元素删除所有默认处理程序,并指定自己的请求处理顺序。

You can remove all default handlers by using clear element in handlers configuration and specify your own request processing order.

我建议将默认IIS处理程序配置(C:\Windows \System32\inetsrv\config\applicationHost.config)复制到您的Web配置,而不使用StaticFile处理程序。

I recommend to copy default IIS handlers configuration (C:\Windows\System32\inetsrv\config\applicationHost.config) to your web config without StaticFile handler at the end.

然后,您应该为每个静态内容类型(jpg,gif,js,css)添加特定的静态内容处理程序。

Then you should add specific static content handler for each static content type (jpg, gif, js, css).

<add name="StaticFile-swf" path="*.swf" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFile-png" path="*.png" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFile-gif" path="*.gif" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFile-jpg" path="*.jpg" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFile-css" path="*.css" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFile-js" path="*.js" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />

和管理处理程序(PageHandlerFactory)。

and manged handler (PageHandlerFactory) for folder requests after that.

<add name="PageHandlerFactory-Folders" path="*" verb="*" type="System.Web.UI.PageHandlerFactory" modules="ManagedPipelineHandler" resourceType="Unspecified" requireAccess="Read" allowPathInfo="false" preCondition="integratedMode" />

最后还应该添加StaticFile处理程序。

At the end you should also add StaticFile handler.

这里是一个示例。

这篇关于BUG:IIS7托管请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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