rename the default class & paste the following code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.SessionState;
namespace ChittyHandler
{
public class clsMyHandler : IHttpHandler,System.Web.SessionState.IRequiresSessionState
{
public bool IsReusable
{
get
{
return true;
}
}
public void ProcessRequest(System.Web.HttpContext objContext)
{
HttpResponse objResponse;
objResponse = objContext.Response;
objResponse.Write(@"This type of file is not served!");
}
}
}
(This is just an example. You may omit inheriting from (or implementing from)
IRequiresSessionState.
Build this class library. With this step you are done with creating HTTP handler
---------------------------------------------------------------------------------------------
Lets see how to consume the HTTP handler in an ASP.NET web application.
---------------------------------------------------------------------------------------------
Add the following line in web.config file:
httpHandlers
add verb="*" path="*.js,*.css" type="ChittyHandler.clsMyHandler,ChittyHandler"
httpHandlers
(namespace.classname,assemblyname)
From ASP.NET appln add a reference to the httphandler you have created just now.
--------------------------------------------------------------------------------------------
Thats it you are done! Very simple. Isn't it!
;-)
For detailed explanation refer to : http://www.15seconds.com/issue/020417.htm
No comments:
Post a Comment