问题
I have an httpmodule class in my class library called API and the httpmodule in this class library is called FileUploadModule.vb.
I have registered the httpmodule in the system.web
section with <add name="FileUploadModule" type="FileUploadModule, API" />
.
Is this the correct way to register an httpmodule?
Why won't my httpmodule fire when i debug the vb.net 2.0 framework web application?
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
回答1:
problem seems about registering.
<httpModules>
<add type="classname, assemblyname" name="modulename" />
<httpModules>
is your assembly name is API?
回答2:
I found an article on stack overflow that helped me also and @adt pointed me in the right direction aswell and got it to work,
Basically i added registered the httpmodule in:-
<system.webServer>
<modules>
<add name="FileUploadModuleControl" type="API.FileUploadModuleControl"/>
</modules>
And it worked!.
The article i found usefule on stackoverflow was at "500 Internal Server Error" when adding HttpModule in my Website?.
来源:https://stackoverflow.com/questions/5149004/httpmodule-wont-fire