Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...IHttpHandler for images presentationIHttpHandler for images presentation
Previous
 
Next
New Post
2/6/2009 10:33 AM
 

 HI. I try to create simple IHttpHandler for showing images from DB. I write some code like this 

public class ImagesProvider : IHttpHandler
{
 public ImagesProvider()
 {
  //
  // TODO: Add constructor logic here
  //
 }

 #region IHttpHandler Members

 public bool IsReusable
 {
  get { return true; }
 }

 public void ProcessRequest(HttpContext context)
 {
  HttpResponse response = context.Response;
  HttpRequest request = context.Request;

  response.Clear();
  response.ContentType = "image/jpeg";

  int fileID = 0;
  if (request.QueryString["fileID"] != null)
  fileID = Convert.ToInt32(request.QueryString["fileID"]);

  string fileType = "";
  if (request.QueryString["fileType"] != null)
  fileType = request.QueryString["fileType"];

  switch (fileType)
  {
  case "sup":
  {
  BaDM_SupplierFile file = null;

  using (OrdersDataDataContext dataRep = new OrdersDataDataContext())
  {
  file = dataRep.BaDM_SupplierFiles.Where(spf => spf.ID == fileID).Single();
  }

  BinaryWriter bw = new BinaryWriter(response.OutputStream);
  bw.Write(file.Data.ToArray());

  } break;
  case "cp":
  { } break;
  }

  response.End();
 }

 #endregion
}
 

And add <add verb="*" path="image.aspx" type="ImagesProvider, App_Code" /> to <httpHandlers> section on my web.comfig

But when I add <img src="image.aspx?fileID=3&fileType=sup" /> to my page nothing is working

 

 
New Post
2/6/2009 1:47 PM
 

Hi,

What do you mean by "nothing is working"? Any error message? Broken image in browser?

I would recommend installing Fiddler (http://www.fiddlertool.com/fiddler/) so you can see the response's content and see exactly what is returned by your handler.

 

 
New Post
2/9/2009 2:11 AM
 

 I mean that ProcessRequest method is not caused

 
New Post
2/9/2009 4:14 AM
 

 Problem has been resolved. At first I tried <img src='image.aspx?params...'  /> for look on my pictures. But, worked nothing... Now I try <asp:Image runat="server" ID="MyPic" ImageUrl="~/image.aspx?params..." /> and all is work!!! :)

 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...IHttpHandler for images presentationIHttpHandler for images presentation


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out