Creating a Synch HttpHandler
Creating a handler for extension .sample
Class must implement the ProcessRequest method and the IsReusable property
Handler must be registered in web.config as under:
configuration system.web httpHandlers
add verb=”*” path=”*.sample” type=”HelloWorldHandler”
httpHandlers system.web configuration
In IIS, right click app directory -> Properties -> Virtual Directory -> Configuration
Mappings -> Click Add, enter Aspnet_isapi.dll, Extension:.sample, clear verify
Code Listing: HttpHandler (Synch)
using System.Web;
public class HelloWorldHandler:IhttpHandler
{
public HelloWorldHandler(){}
public void ProcessRequest(HttpContext context)
{
HttpRequest Request = context.Request;
HttpResponse Response = context.Response;
Response.Write(html);
Response.Write(“body”);
Response.Write(“Hello World, you requested a resource with extension .sample”);
Response.Write(“/body”);
Response.Write(/html);
}
public bool IsReusable
{
get
{
return false;
}
}
}
No comments:
Post a Comment