Introducing HTTPHandlers
page 2 of 4
by . .
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 26271/ 40

Creation and Setup
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.


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-24 6:10:00 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search