Creation
Creating an HTTPHandler is much the
same as an HTTPModule -
Imports System
Imports System.Web
Public
Class
SampleHandler : Implements
IHttpHandler
Public
Sub
ProcessRequest(ByVal
context As
HttpContext) Implements
IHttpHandler.ProcessRequest
context.Response.ContentType = "text/xml"
context.Response.Write("<time>")
context.Response.Write("<GMT>")
context.Response.Write(DateTime.Now.Subtract(New
TimeSpan(12, 0, 0)).ToString())
context.Response.Write("</GMT>")
context.Response.Write("</time>")
End
Sub
Public
ReadOnly
Property
IsReuseable() As
Boolean
Implements
IHttpHandler.IsReusable
Get
Return
True
End
Get
End
Property
End
Class |
In web.config -
<httpHandlers>
<add
verb="*"
path="*.gmt"
type="HttpModHan.SampleHandler,
HttpModHan"
/>
</httpHandlers> |
The verb part is just what you want it
to respond to (eg. POST, GET etc.). Path is the specific file or file
extension you want it to respond to and Type is still the same -
ClassName, Assembly.