This project is read-only.

Image.axd not working

Topics: ASP.NET 2.0, Business Logic Layer
Nov 19, 2010 at 9:51 PM


I just installed BE and have everything working but the images. When I upload an image into a post/page, nothing gets displayed. I Checked the source code and the image is indeed there. But it seems that the handler is not working for some reason.

If I try to access the handler alone (that's it, without any parameters) I get a blank page (I expected that), but if I pass the path inserted on the editor (/image.axd?picture=2010%2f11%2f19.jpg), I get the 404 page. The image IS under App_Data/files/2010/11/19.jpg

Any ideas on how to get this working?

Nov 20, 2010 at 2:36 AM

Sounds like it should be working.

The image handler will display the 404 page if either the file is missing or if an unhandled error occurs.  When this happens, it does raise an event you could tap into.  In default.aspx.cs (in the blog root), you could add the following code into at the top, right after "public partial class ...":

private static void ImageHandler_BadRequest(object sender, EventArgs e)
    string log = "\r\n" + DateTime.Now.ToString() + ": ";
    log += (sender == null ? "sender is null" : sender.ToString());
    string path = BlogEngine.Core.BlogSettings.Instance.StorageLocation + "imagehandler.log";
    path = System.Web.Hosting.HostingEnvironment.MapPath(path);
    System.IO.File.AppendAllText(path, log);

static _default()
    BlogEngine.Core.Web.HttpHandlers.ImageHandler.BadRequest += new EventHandler<EventArgs>(ImageHandler_BadRequest);
This would then record information from the image handler if one of these 2 situations occurs.  It will record it in a new file, imagehandler.log in the App_Data directory.  You might see a 2nd log record of "Thread was being aborted.".  That's not important.  If the file cannot be found, the error message will just be the name of the file it was looking for.  But if an unhandled error occurs, then the error message that gets recorded should contain the error message.

Nov 21, 2010 at 11:00 PM

I did what you said and no error message is being recorded in the app_data.

After some fiddling, I fixed the issue by changing the web server configuration from integrated mode to classic.