text: Member
  1 Points
  Jul 08, 2010 03:24 PM|kverreault|LINK
  I am currently designing a web page for a photography club. Members can upload their pictures, organize contests and rate other members pictures. In the rating page I resize the pictures so it can fit in the screen. If a member wants to see the full size he can click on it to display the full picture in my handler. I pass the id of the picture in the querystring to the handler so he can retrieve the physical path in the database (all the pictures are stored on the server and I keep the paths in the database) and display the picture.
  I always get this error message : An invalid character was found in text content. Error processing resource.
  namespace Photoclub
  {
  public class AfficherPhoto : IHttpHandler
  {
  public void ProcessRequest(HttpContext context)
  {
  try
  {
  context.Response.ContentType = "image/jepg";
  int id = Convert.ToInt32(context.
  DBPhoto db = new DBPhoto();
  string path = db.GetPath(id);
  Image img = Image.FromFile(path);
  img.Save(context.Response.
  }
  catch (Exception ex)
  { throw new Exception(ex.Message); }
  }
  public bool IsReusable
  {
  get { return true; }
  }
  }
  }
  I searched different ways to display a jpeg in an HttpHandler on google but I always get the same error. I'm out of ideas and I can't find what is wrong with my code. If anyone could help it would be greatly appreciated ! The air conditioning is broken at work and this error is driving me crazy :p
  Kevin Verreault
  Image Handler dynamic Image httphandler HTTP Handler
  1 reply
  Last post Jul 09, 2010 05:53 AM by johnyM456