1. What is Http Handlers?
- ASP.NET HttpHandler is a class that implements the System.Web.IHttpHandler interface.
- HTTPHandlers are used by ASP.NET to handle the specific requests based on extensions.
- There is one Handler for a specific request but there could be N number of modules for that.
- The class should have a method ProcessRequest and a property called IsReusable.
- Web.config settings
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="*.sync" type="MyHandler.SyncHandler, MyHandler" />
</httpHandlers>
</system.web>
</configuration>
In the verb="*" attribute, we instruct the handler to process a request that uses any verb (for example, POST, HEAD, GET, and so on).
If you want this handler to process only the POST request, change this to verb="POST".
In the path="*.sync" attribute, we instruct the handler to process any incoming requests for files with the .sync extension.
In the type="MyHandler.SyncHandler, MyHandler" attribute, we instruct the handler that processes the request to implement in the MyHandler.SyncHandler
namespace, and this class resides in the MyHandler assembly.
6.ASP.NET offers a few default HTTP handlers:
- Page Handler (.aspx): handles Web pages
- User Control Handler (.ascx): handles Web user control pages
- Web Service Handler (.asmx): handles Web service pages
- Trace Handler (trace.axd): handles trace functionality
2.What is Http Modules?
- ASP.NET Http Modules is a class that implements the System.Web.IHTTPModule interface.
- Http Modules are used by ASP.NET to handle the requests based on events.
- There are N number of modules one for a specific Handler for that.
- The class should have two methods Init and Dispose.
- Web.config settings
<system.web>
<httpModules>
<add name="MyModule"type="MyModule.SyncModule, MyModule" />
</httpModules>
</system.web>
6. The built-in modules in ASP.NET are:
- Output Cache Module
- Windows Authentication Module
- Forms Authentication Module
- Passport Authentication Module
- URL Authorization Module
- File Authorization Module
3. Difference between Http Handlers and Http Modules
- HTTP handlers are the end point objects in ASP.NET pipeline.
- HTTP Modules are objects which participate the pipeline but they work before and after the HTTP Handler.
- HTTP Handlers are extensions based.
- HTTP Modules are events based.
- There is one Handlers for a specific request.
- There are many handlers for a specific request.
- Implements the System.Web.IHttpHandler interface.
- Implements the System.Web.IHTTPModule interface.
4. Processing Sequence of Http Handlers and Http Modules
In the asp.net request pipe line, http Module comes first.
No comments:
Post a Comment