Description:
HTTP handlers are .net components that is used the process the incoming request based on the mapped file name extension in the configuration files (machine.config or web.config). ASP.NET framework defines some built-in handlers for processing.
Example:
ASP.NET Page Handler: Handles the request from ASP.NET web pages having extention .aspx
Web Service Handler: Handlers the web service files having extenstion (*.asmx)
User Control Handler: Handlers user controls files with extension (*.ascx)
HTTP handlers are divided in to two types depending upon the way of generating output of the incoming request.
1. Synchronous HTTP Handler
2. Asynchronous HTTP Handler
Synchronous handlers does not return it's processed output until it finishes complete processing of the request, while asynchronous handlers runs a separate process independently to send the response back to user asynchronously.
Creating Custom HTTP Handler:
To create a custom synchronous HTTP handler you need to implement the IHttpHandler interface and similarly for creating a custom asynchronous HTTP handler it is required to implement IHttpAsyncHandler interface. In both the cases it is required to implement the IsReusable property and ProcessRequest() method.
IsReusable property determines whether the handler is placed in pool for re-use or it is re-created every time it is required and ProcessRequest() method do the processing of each request.
Note: Session state is not by default enabled for HTTP Handlers, to enable it you have to implement the IRequiresSessionState or IReadOnlySessionState interface. These two are marker interfaces and there is no method to implement.
Configuring Custom HTTP Handler:
After creating custom HTTP handler it is required to configure the web server and application to map the incoming request to be handled by the handler.
Steps to configure:
1. Map the file extension that is going to be processed by your custom handler to ASP.NET ISAPI dll (aspnet_isapi.dll) in the Internet Service Manager.
2. Modify the web.config or machine.config file to register your handler.
Note: I have described steps to create a HTTP Handler on this post "Steps to create HTTP Handler"
HTTP handlers are .net components that is used the process the incoming request based on the mapped file name extension in the configuration files (machine.config or web.config). ASP.NET framework defines some built-in handlers for processing.
Example:
ASP.NET Page Handler: Handles the request from ASP.NET web pages having extention .aspx
Web Service Handler: Handlers the web service files having extenstion (*.asmx)
User Control Handler: Handlers user controls files with extension (*.ascx)
List of the mapped HTTP Handler you will find in the config file |
1. Synchronous HTTP Handler
2. Asynchronous HTTP Handler
Synchronous handlers does not return it's processed output until it finishes complete processing of the request, while asynchronous handlers runs a separate process independently to send the response back to user asynchronously.
Creating Custom HTTP Handler:
To create a custom synchronous HTTP handler you need to implement the IHttpHandler interface and similarly for creating a custom asynchronous HTTP handler it is required to implement IHttpAsyncHandler interface. In both the cases it is required to implement the IsReusable property and ProcessRequest() method.
IsReusable property determines whether the handler is placed in pool for re-use or it is re-created every time it is required and ProcessRequest() method do the processing of each request.
Note: Session state is not by default enabled for HTTP Handlers, to enable it you have to implement the IRequiresSessionState or IReadOnlySessionState interface. These two are marker interfaces and there is no method to implement.
Configuring Custom HTTP Handler:
After creating custom HTTP handler it is required to configure the web server and application to map the incoming request to be handled by the handler.
Steps to configure:
1. Map the file extension that is going to be processed by your custom handler to ASP.NET ISAPI dll (aspnet_isapi.dll) in the Internet Service Manager.
2. Modify the web.config or machine.config file to register your handler.
Note: I have described steps to create a HTTP Handler on this post "Steps to create HTTP Handler"
No comments:
Post a Comment
Your comments are valuable.