【问题标题】:HttpModule wont fireHttpModule 不会触发
【发布时间】:2011-02-28 23:53:33
【问题描述】:

我的类库中有一个名为 API 的 httpmodule 类,该类库中的 httpmodule 名为 FileUploadModule.vb。

我已经在system.web 部分中使用<add name="FileUploadModule" type="FileUploadModule, API" /> 注册了httpmodule。

这是注册httpmodule的正确方法吗?

当我调试 vb.net 2.0 框架 web 应用程序时,为什么我的 httpmodule 不会触发?

Public Class FileUploadModule
Implements IHttpModule

Public Sub Dispose() Implements System.Web.IHttpModule.Dispose
End Sub

Public Sub Init(ByVal context As System.Web.HttpApplication) Implements System.Web.IHttpModule.Init
    AddHandler context.BeginRequest, AddressOf OnBeginRequest
End Sub

Public Sub OnBeginRequest(ByVal sender As Object, ByVal e As EventArgs)
    Dim app As HttpApplication = CType(sender, HttpApplication)
    app.Context.Response.Write("ddddddddddddddddddd")
End Sub

End Class

【问题讨论】:

    标签: asp.net vb.net httpmodule file-upload


    【解决方案1】:

    注册似乎有问题。

    <httpModules>
        <add type="classname, assemblyname" name="modulename"  />
    <httpModules>
    

    你的程序集名称是 API 吗?

    【讨论】:

    • @adt 是的,程序集名称是 API,类名称是 FileUploadModule,但我也试过了,但没有运气,断点没有击中代码。
    • haacked.com/archive/2008/07/02/… 你能试试这个例子吗?这毫无疑问是有效的。
    • @Trikam 是您无法调试它的问题,或者您无法在应用程序中看到 ddddddd 的每一个 rewuest?
    • @adt,不,它对我不起作用,我需要将任何设置添加到模块标签或 iis 中吗?我正在使用 Windows 7。我在实现 httphandler 时遇到了同样的问题,但我通过添加 '' 并且它工作但我使用 iggpmodule 所以它应该与使用 httphandler 不同。
    • 将 httpmodule 添加到 web.config 文件的 system.webserver 中。或使用 IIS 的 UI 添加它。这个问题肯定是关于将模块注册到 web.config :)
    【解决方案2】:

    我发现一篇关于堆栈溢出的文章也对我有帮助,@adt 也为我指出了正确的方向并让它发挥作用,

    基本上我在以下位置添加了注册httpmodule:-

    <system.webServer>
      <modules>
         <add name="FileUploadModuleControl" type="API.FileUploadModuleControl"/>
      </modules>
    

    它成功了!。

    我在 stackoverflow 上发现有用的文章位于 "500 Internal Server Error" when adding HttpModule in my Website?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-10
      • 1970-01-01
      • 1970-01-01
      • 2019-08-07
      • 2011-09-30
      相关资源
      最近更新 更多