gpt4 book ai didi

c# - preCondition ="managedHandler"如何用于模块?

转载 作者:可可西里 更新时间:2023-11-01 08:10:59 25 4
gpt4 key购买 nike

在阅读了一些关于集成管道的文档后,我对 IIS 如何确定何时运行托管模块、托管请求实际上是什么以及如何确定感到困惑,例如:

http://www.iis.net/learn/application-frameworks/building-and-running-aspnet-applications/aspnet-integration-with-iis http://blogs.msdn.com/b/tmarq/archive/2007/08/30/iis-7-0-asp-net-pipelines-modules-handlers-and-preconditions.aspx

多次提到“托管”请求。有一个实例解释了托管请求是一个映射到托管处理程序的请求。还有一句话说处理程序是一个“特殊”模块(第二个链接)。

模块被描述为针对每个 请求运行的东西,并且处理程序具有指定何时运行的映射(例如,*.aspx 的 HTTP GET)(第二个和第一个链接)。此外,对于模块,execute_request_handler [我假设它是处理程序实际运行的点] 出现在管道的几个阶段之后(在 begin_request、authenticate、authorize 等之后),这意味着有一个步骤发生在所有这一切之前,确定请求是针对托管处理程序的,以便在请求不是针对托管处理程序时禁用具有 preCondition="managedHanlder"的模块的执行。

我觉得这里缺少一些东西,有人可以阐明 preCondition="managedHandler"到底是如何工作的吗?

最佳答案

来自这篇博文 (http://blogs.iis.net/thomad/archive/2006/11/04/precondition-what.aspx):

The ManagedHandler precondition

IIS 7.0 introduces a new managed extensibility model. Handlers and Modules can now be written in managed code and directly integrated into the IIS request pipeline. But switching between managed and native code is an expensive operation. The managedHandler precondition was introduced to allow optimizing the performance of requests where no managed code needs to be involved, for example when static files (.html, .jpg etc.) are served. No managed code is called if the request is served by a native handler and every managed module is configured with the managedHandler precondition. A practical scenario is Forms authentication. The managed Forms authentication module has a managedHandler precondition and is therefore only called when ASP.NET content (e.g. *.aspx) pages are requested. If a .html page is requested the forms authentication is not called. If you want to protect all your content with forms authentication you can simply remove the managedHandler precondition from the Forms authentication module entry.

简而言之,如果请求可以由 native IIS 模块(例如图像)提供服务,则它不必经过所有托管管道(例如,所有“global.asax”事件和甚至更多),从而带来巨大的性能提升。

编辑:您问题的实际答案是:处理程序映射。这就是将文件扩展名关联到特定处理程序的原因。您将在下面找到如何在 II7 中编辑这些映射。您还可以找到有关处理程序映射的更多信息 here .

open this section in IIS

Then you will see all the registered mappings

关于c# - preCondition ="managedHandler"如何用于模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18989449/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com