HttpModule 未与 Visual Studio 一起运行

发布于 2024-07-23 14:29:15 字数 681 浏览 3 评论 0原文

我正在使用 HttpModule 在我的网站上进行一些 URL 缩短。 我正在使用 Visual Studio 2008 和 IIS 7 以及 .Net 3.5。

当在 web.config 的 system.webServer 元素中指定该模块并且站点在 IIS 中运行时,它可以正常工作。 配置如下所示:

<system.webServer>
        <modules>
            <add name="MinimizeModule" type="ClipperHouse.UrlMinimizer.MinimizeModule" />
        </modules>...

我的模块附加到 BeginRequest 事件,一切正常。 但是,我无法使用内置 VS Web 服务器(Cassini)运行它。 我尝试将模块配置移动到 web.config 中的 system.web 元素,但没有成功。 我在上面设置了断点,什么也没有发生。

对于为什么这会成为一个问题有什么想法吗?

(我还尝试了 global.asax 中的 Application_BeginRequest 事件。仍然没有运气,尽管我更愿意将所有内容保留在 web.config 中。)

I am using an HttpModule to do some URL shortening on my site. I am using Visual Studio 2008 and IIS 7, and .Net 3.5.

When the module is specified in the system.webServer element of web.config, and the site is run in IIS, it works fine. The config looks like this:

<system.webServer>
        <modules>
            <add name="MinimizeModule" type="ClipperHouse.UrlMinimizer.MinimizeModule" />
        </modules>...

My module attaches to the BeginRequest event, everything works. However, I can't get it to run using the built-in VS web server (Cassini). I tried moving the module config to the system.web element in web.config, no luck. I put a breakpoint on it, nothing happens.

Any thoughts on why this would be an issue?

(I also tried the Application_BeginRequest event in global.asax. Still no luck, though I'd prefer to keep everything in web.config anyway.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

以酷 2024-07-30 14:29:15

Cassini,IIS 提供的开发 Web 服务器使用 IIS6 模块语法,因此您必须像这样复制模块添加

<system.web>
  <httpModules>
    <add name="MinimizeModule" type="ClipperHouse.UrlMinimizer.MinimizeModule" />
  </httpModules>
</system.web>


<system.webServer>
  <validation validateIntegratedModeConfiguration="false"/>
  <modules>
    <remove name="MinimizeModule" />
    <add name="MinimizeModule" type="ClipperHouse.UrlMinimizer.MinimizeModule" 
         preCondition="managedHandler" />
  </modules>
</system.webServer>

请注意,我还为您的 IIS7 设置添加了前提条件

Cassini, the development web server provided with IIS uses the IIS6 module syntax, so you must duplicate the module add like so

<system.web>
  <httpModules>
    <add name="MinimizeModule" type="ClipperHouse.UrlMinimizer.MinimizeModule" />
  </httpModules>
</system.web>


<system.webServer>
  <validation validateIntegratedModeConfiguration="false"/>
  <modules>
    <remove name="MinimizeModule" />
    <add name="MinimizeModule" type="ClipperHouse.UrlMinimizer.MinimizeModule" 
         preCondition="managedHandler" />
  </modules>
</system.webServer>

Note that I've also added a precondition to your IIS7 settings

清欢 2024-07-30 14:29:15

如果您在 IIS 7 上运行,请将该模块放入:

<configuration>
   <system.webServer>
      <modules>
         <add name="MinimizeModule" type="ClipperHouse.UrlMinimizer.MinimizeModule" />
      </modules>
   </system.webServer>
</configuration>

如果您在 Cassini(Visual Studio 的集成微型 Web 服务器)上运行,请将该模块放入:

<configuration>
   <system.web>
      <httpModules>
          <add name="MinimizeModule" type="ClipperHouse.UrlMinimizer.MinimizeModule" />
   </system.web>
</configuration>

如果给它 Cassini 位置,IIS 将崩溃。
如果您向 Cassini 提供 IIS 位置,它将会崩溃。

每当我部署时,我必须确保不部署web.config。 我还在 web.config 中添加了注释:

<system.web>
   <!--The Cassini location to add modules (comment out for IIS)-->
   <httpModules>
      <!--WARNING: IIS will crash if you leave this in here.
          IISBUG: IIS doesn't support system.web/httpModules, 
          and Cassini doesn't support system.webServer/modules
      -->
      <!--Comment out for IIS-->
      <add name="PerformanceHttpModule" type="DummyPlaceholder.PerformanceHttpModule"/>
   </httpModules>
</system.web>

<system.webServer>
   <!--The IIS7 location to add modules (comment out for Cassini)
   <modules runAllManagedModulesForAllRequests="true">
      <!--IIS7 will crash if you present a system.web httpModules. -->
      <remove name="PerformanceHttpModule" />
      <add name="PerformanceHttpModule" type="DummyPlaceholder.PerformanceHttpModule"/>
   </modules>
</system.webServer>

IIS 的左手不知道 Cassini 的右手在做什么 - 他们都搞砸了。

If you are running on IIS 7, put the module in:

<configuration>
   <system.webServer>
      <modules>
         <add name="MinimizeModule" type="ClipperHouse.UrlMinimizer.MinimizeModule" />
      </modules>
   </system.webServer>
</configuration>

If you are running on Cassini (Visual Studio's integrated miniature web-server), put the module in:

<configuration>
   <system.web>
      <httpModules>
          <add name="MinimizeModule" type="ClipperHouse.UrlMinimizer.MinimizeModule" />
   </system.web>
</configuration>

IIS will crash if you give it the Cassini location.
Cassini will crash if you give it the IIS location.

Whenever i deploy, i have to be sure not to deploy web.config. i also include the notes in web.config:

<system.web>
   <!--The Cassini location to add modules (comment out for IIS)-->
   <httpModules>
      <!--WARNING: IIS will crash if you leave this in here.
          IISBUG: IIS doesn't support system.web/httpModules, 
          and Cassini doesn't support system.webServer/modules
      -->
      <!--Comment out for IIS-->
      <add name="PerformanceHttpModule" type="DummyPlaceholder.PerformanceHttpModule"/>
   </httpModules>
</system.web>

<system.webServer>
   <!--The IIS7 location to add modules (comment out for Cassini)
   <modules runAllManagedModulesForAllRequests="true">
      <!--IIS7 will crash if you present a system.web httpModules. -->
      <remove name="PerformanceHttpModule" />
      <add name="PerformanceHttpModule" type="DummyPlaceholder.PerformanceHttpModule"/>
   </modules>
</system.webServer>

IIS's left hand doesn't know what Cassini's right hand is doing - and they both screwed it up.

一人独醉 2024-07-30 14:29:15

您是否尝试将模块声明也放入元素中? 当使用 Cassini 在开发中运行时,这通常是我必须放置模块以使它们运行的​​地方。

Did you try also putting the module declaration in the element? When running in dev using Cassini, that's usually the place I have to put modules to get them running.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文