Question

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

Hello Guys,
I'm trying to implement IHttpHandler for the first time ,I thought I was going ok,but it's not. My gridview was not showing Image ,I used Img tag and used URL of the ImageHandler

<ItemTemplate>
 <img src="ImageHandler.ashx?autoid=<%# DataBinder.Eval(Container.DataItem,"Blob_Id") %>" width="150" height="100" />
 </ItemTemplate>

Note: ImageHandler.ashx (actually have the .cs extension,does it have to be .ashx ?)

My GridView was showing empty image like this, enter image description here

When I RightClicked Image and selected Properties and found the link. http://localhost/MySite/Presentation/ImageHandler.ashx?autoid=j01 I pasted that link on another tab and this error came up ,since the ImageHandler needs the ImageId and sends the Image in return ,it should have send image.

Error Message:

Exception Details: System.IO.FileNotFoundException: File or assembly name ImageHandler, or one of its dependencies, was not found.

P.S:

  • ImageHandler (which implements IHttpHandler) is actually a .cs file in ace directory.
  • I have followed this article

Update:

It seems like the ImageHandler is not properly registered as the HttpHandler, because I have changed the ImageHandler name to a fake Handler such as FakeName.ashx so when I request that link it gives the same error as mentioned above.

Was it helpful?

Solution

There's no need to register HTTP handlers really. You can just drop an .ashx file and hit it and it works as long as the .ashx file is on the website and the code is also inside the .ashx file.

Can you show me the code of the handler?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top