Pregunta

Tool: Visual Studio 2003 Enterprise Architect , ASP.net WebForms
Language: C#

Hello Guys,

I have just implemented HttpHandler for the first time ,I thought I was going ok ,but I'm facing this error

Error Message:

Error while trying to run poject: Unable to start debugging on the web server. Server side-error occurred on sending debug HTTP request. Make sure the erver is operating correctly.Verify there are no syntax errors in web.config by doing a Debug.start Without Debugging. You may also want to refer to the ASP.NET and ATL Server debugging topic in the online documentation.

CODE:
I have ImageHandler.cs class

public class ImageHandler : IHttpHandler
{
 public ImageHandler()
 {
 }
 public void ProcessRequest(HttpContext context) 
 { 
       //blah blah code
       bytes = (byte[])cmd.ExecuteScalar();
   context.Response.BinaryWrite(bytes);
     }
    }

I have registered WebHandler on the page where I would call for request,

<%@ WebHandler Language="C#" Class="ace.ImageHandler" %>

I'm calling HttpHandler from gridView

    <asp:TemplateColumn>
   <ItemTemplate>
       <img src="ImageHandler.ashx?autoid=<%# Eval("Blob_Id").ToString() %>" width="150" height="100" />
     </ItemTemplate>
    </asp:TemplateColumn>

Registered the handler in Web.Config

 <httphandlers>
  <add verb="GET" path="ace\ImageHandler.ashx" type="ace.ImageHandler, ImageHandler" />
 <httphandlers>

Update:

I used Debug > Start without Debugging and WebApp executed and got this error.

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Unrecognized configuration section 'httphandlers'

Source Error:

Line 9:   <system.web>
Line 10:    
Line 11:  <httphandlers>
Line 12:   <add verb="*" path="*.ashx" type="ace.ImageHandler, ImageHandler" />
Line 13:   <httphandlers>

Note: ace is the namespace and ImageHandler.cs is a class

P.S: I have followed this article

¿Fue útil?

Solución

It should be <httpHandlers> with the second H as a capital letter. I just tried it on my project, and the capitalization matters.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top