如何部署一个管理HTTP模块站点范围? [英] How do I deploy a managed HTTP Module Site Wide?

查看:163
本文介绍了如何部署一个管理HTTP模块站点范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发manged的HTTP模块,这将拦截请求和从IIS 7.响应截获消息将基于由自定义过滤器的一组业务规则进行修改。业务规则将存储在配置文件

I am developing a manged HTTP Module that will intercept requests to and response from IIS 7. The intercepted messages will be modified based on a set of business rules by a custom filter. The business rules will be stored in a configuration file.

该信息必须广泛截获的网站。这包括存在作为网站的儿童的任何应用程序或虚拟目录。在此我第一次尝试安装HTTP模块组装所需网站的bin目录(例如C:\的Inetpub \ wwwroot的\ bin作为默认Web站点)。

The messages must be intercepted web site wide. This includes any applications or virtual directories that exist as children of the web site. My first attempt at this was to install the HTTP Module assembly in the bin directory of the desired web site.(e.g., C:\inetpub\wwwroot\bin for the Default Web Site).

在安装我修改<编译> 网​​站的web.config文件中的元素以引用的程序集,像这样:

Once installed I modify the <compilation> element of the web site's web.config file to reference the assembly, like so:

<compilation debug="false">
    <assemblies>
        <add assembly="Company.Product.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx" />
    </assemblies>
</compilation>

我还修改了&LT;模块&gt; 网​​站的web.config文件中的元素

I also modified the <modules> element of the web site's web.config file.

<system.webServer>
    <modules>
        <add name="MyModule" type="Company.Product.Module.MyModule" />
    </modules>
</system.webServer>

这可以很好地用于网站下的大部分内容。但是,如果出现(例如,/ wwwroot文件/所有MyApplication)网站下配置了应用程序,我在该Web应用程序导航到任何资源时,收到以下错误:

This works well for most content under the web site. However, if there is an application configured under the website (e.g., /wwwroot/MyApplication) I receive the following error when navigating to any resource under that web application:

无法加载文件或程序集   Company.Product.Module,   版本= 1.0.0.0,文化=中立,   公钥= XXXXXXXXXXXXXXXX或   它的一个依赖。系统   找不到指定文件。

Could not load file or assembly 'Company.Product.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx' or one of its dependencies. The system cannot find the file specified.

有两种方法,我知道要解决这个问题:

There are two ways I know to get around this:

选项1:

复制HTTP模块组装和所有相关组件,以每个应用程序的bin目录。我相信,我还需要重复从父目录的配置信息。这可以成为一个管理梦魇,因为越来越多的应用程序被添加到网站上。

Copy the HTTP Module assembly and all dependent assemblies to each application's bin directory. I believe that I would also need to duplicate the configuration information from the parent directory. This can become a management nightmare as more and more applications are added to the web site.

选项2:

安装HTTP模块组装和GAC所有相关组件。这似乎工作得很好,避免了大量的管理费用,然而,在没有配置信息住在哪里?如果在网站的web.config文件是这样的信息,继承了所有的子应用程序?

Install the HTTP Module assembly and all dependent assemblies in the GAC. This seems to work quite well and avoids a lot of management overhead, however, where does configuration information live? If in the web site's web.config file is this information inherited in all the child applications?

什么是广泛部署托管的HTTP模块的网站上推荐的方法?应该如何配置来处理,以便所有配置是在一个中心位置?

What is the recommend method for deploying a managed HTTP Module site wide? How should configuration be handled so that all configuration is in a central location?

推荐答案

您可以GAC这个dll,但它会破坏你的X复制部署的故事,如果你已经有一个到位。如果它是确定和你在一起,你可以在以后该模块添加到配置中的applicationHost.config在位置标签:&LT;位置路径=mysite的&GT中,&lt;位置路径=mysite的/ MyApp的 &GT;

You can GAC this dll, but it would break your x-copy deployment story if you already have one in place. If it is ok with you, you can later add this module to configuration in applicationHost.config in location tags: <location path="MySite">, <location path="MySite/MyApp">

这篇关于如何部署一个管理HTTP模块站点范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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