Click here to Skip to main content
15,921,028 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
Dear All

when i add webhandler in my .ashx file it is not accepted, any one give me the solution for this

My handler code:


<% @ WebHandler language="C#" class="WebUI2.DownHandler" codebehind="DownHandler.cs" %>

Thanks
Sathik
Posted

1 solution

CodeBehind not used at runtime, make sure that you have given class name correctly and class implemented IHttpHandler interface
sample code:
C#
<%@ WebHandler Language="C#" Class="Handler" %>

using System;
using System.Web;

public class Handler : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        context.Response.Write("Hello World");
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900