HTTP Handlers in ASP.NET
|HTTP Handlers in ASP.NET|
Download: Examplehandler.rar 3Kb
The low level Request and Response API to service incoming Http requests are Http Handlers in Asp.Net. All handlers implement the IHttpHandler interface, which is located in the System.Web namespace. Handlers are somewhat analogous to Internet Server Application Programming Interface (ISAPI) extensions.
The following are the methods in Http Handlers.
Configuring HTTP Handlers
The <httpHandlers> configuration section handler is responsible for mapping incoming URLs to the IHttpHandler or IHttpHandlerFactory class. It can be declared at the computer, site, or application level. Subdirectories inherit these settings.
Creating HTTP Handlers
To create an HTTP handler, you must implement the IHttpHandler interface. The IHttpHandler interface has one method and one property with the following signatures:
Compile it and place it in the bin directory of TestApp project.
Go to Internet Information Services and select Default Web Site. Right Click and Select Properties. Select Home Directory and click on Configuration. The Following Screen will appear:
Click on Add and give executable path and new extension and click OK.
Close IIS and Run TestApp website by using the URL
The output will be as follows:
The sensitive files can be protected by Http Forbidden Handler. The Database driven web sites using MS Access, the .mdb file has to be protected. To protect the .mdb files, we must follow the two steps given below:
The Http Handlers are often useful when the services provided by the high-level page framework abstraction are not required for processing the HTTP request. Common uses of handlers include filters and CGI-like applications, especially those that return binary data.