you need to type the CustomHttp.test filename at the end of the URL and press the enter to start the Custom HTTPHandler.
Interviews3 answers
ASP.NET Interview question :- How do we write a HttpHandler ?
3 Answers
CustomHttp.test is the name of the file that launches the HTTPHandler.
sarika jainPosted Feb 28, 2011, 9:54 PM EST
First Create a class
public class CustomHandler:IHttpHandler
{
public bool IsReusable
{
get
{ return true; }
}
public void ProcessRequest(System.Web.HttpContext context)
{
HttpResponse response=context.response;
Response.Write("<html><body><h2>Sample HTTP Handler</h2></body></html>");
}
Do this in web.config file
<compilation debug="true"/>
<authentication mode="Windows"/>
<httpHandlers>
<add verb="*" path="CustomHttp.test" type="CustomHTTP.CustomHandler"/>
</httpHandlers>
sarika jainPosted Feb 28, 2011, 9:51 PM EST
Answer:
This is a simple a .NET Interview question .Its a two step process.
First create a class which implements Ihttphandler
public class clsHttpHandler : IHttpHandler
{
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
// Put implementation here.
}
}
Step 2 make a entry in the web.config file.
<httpHandlers>
<add verb="*" path="*.gif" type="clsHttpHandler"/>
</httpHandlers>
You can view my top
ASP.NET
Interview questions and answers
Shivprasad KoiralaPosted Feb 26, 2011, 3:44 AM EST