I am trying to register a custom HttpHandler in the web.config file. MSDN's example shows an entry that is commented out...um which doesn't work so well. When I uncomment I receive a Could not load file or assembly 'HttpModule.cs' or one of its dependencies. The system cannot find the file specified.
error. The file name is HttpModule.cs and the class name is MyHttpModule. There is no explicit namespace yet.
<httpModules> <add name="MyHttpModule" type="MyHttpModule, HttpModule" /> <httpModules>
I am sure I am overlooking the obvious. Do I need to specify the file path somewhere? Thanks in advance.
In the Connections pane, expand the server name, expand Sites, and then go to the Web site or application to which you want to add a managed module. In the Home pane, double-click Modules. In the Actions pane, click Add Managed Module.
An HTTP module is an assembly that is called on every request that is made to your application. HTTP modules are called as part of the ASP.NET request pipeline and have access to life-cycle events throughout the request. HTTP modules let you examine incoming and outgoing requests and take action based on the request.
HTTP modules and HTTP handlers are an integral part of the ASP.NET architecture. While a request is being processed, each request is processed by multiple HTTP modules (for example, the authentication module and the session module) and is then processed by a single HTTP handler.
HTTPHandlers. ASP.Net HTTPHandler is a process that runs in response to a request made to an ASP.Net application. When a client makes a request to a server resource, each request is handled by HTTPHandler based on the request file extension (. aspx, . asmx etc).
I am still learning much of the terminology and needed it spelled out for me. In case any of you need the same...
As an example if:
TestSite
BusinessLogic
PageAuthorization
in the Web.config file...
<configuration> <system.web> <httpModules> <add type= "BusinessLogic.PageAuthorization, TestSite" name="PageAuthorization" /> </httpModules> </system.web> </configuration>
In my case I had to mark my class with IHttpModule
. The definition of the class would look like:
public class PageAuthorization : IHttpModule
If you are loading Custom module from .Net 4.0 GAC and IIS 6/7 classic mode you have to use below code
<system.web> <httpModules> <add name="ClientHttpModule" type="ClientServHttpModule.ClientHttpModule,ClientServHttpModule,Version=1.0.0.0, Culture=neutral, PublicKeyToken=3af8d8e2f9e8b6c3" /> </httpModules> </system.web>
ClientServHttpModule is namespace of your custom module. Public key token you can get it from sn.exe app.
if you are running in Integrated mode.use below code
<system.webServer> <modules> <add name="ClientHttpModule" type="ClientServHttpModule.ClientHttpModule,ClientServHttpModule,Version=1.0.0.0, Culture=neutral, PublicKeyToken=3af8d8e2f9e8b6c3" /> </modules> </system.webServer>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With