asp.net - 如何将泛型类注册为 IHttpModule

标签 asp.net fluent-nhibernate

public class NHibernateSessionPerRequest<T>:IHttpModule
{
    public void Dispose() { }

    public void Init(HttpApplication context)
    {
        context.BeginRequest += BeginRequest;
        context.EndRequest += EndRequest;
    }
}

如何在web.config中注册?

最佳答案

IIS6:在 web.config 的 system.web 部分

<configuration>
  <system.web>
    <httpModules>
      <add name="MyModule" type="My.Namespace.NHibernateSessionPerRequest`1[[My.Namespace.MyType, My.Assembly]], My.Assembly"/>
    </httpModules>
  </system.web>
</configuration>

IIS7:在 web.config 的 system.webserver 部分:

<configuration>
  <system.webServer>
    <modules>
      <add name="MyModule" type="My.Namespace.NHibernateSessionPerRequest`1[[My.Namespace.MyType, My.Assembly]], My.Assembly"/>
    </modules>
  </system.webServer>
</configuration>

对于两者,将“My.Namespace”替换为类的命名空间,将“My.Assembly”替换为程序集名称。

关于asp.net - 如何将泛型类注册为 IHttpModule,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4138794/

相关文章:

ASP.NET 4.0 DropDownList 在文本中带有单引号

c# - Fluent NHibernate Reveal 不使用给定的属性名

c# - 在 Fluent NHibernate 中,如何将自动映射类型与非自动映射类型结合起来?

asp.net - 为什么 FireFox 3.6.8 不缓存来自 asp.net 开发者服务器的静态内容?

ASP.NET SSO 和构建自定义 STS

c# - 在 Entity Framework (Oracle 或 SQL Server)中检测 dbms 类型

nhibernate - 带排序的流畅映射多对多

c# - 如何从 JavaScript/C# 生成宽度 CSS

c# - Fluent Nhibernate 映射通过两个非主键列连接

fluent-nhibernate - Fluent NHibernate 3 uniquekey自定义约束名称