I don’t know if it is relevant that this is happening in an MVC website but thought I’d mention it anyway.
In my web.config I have these lines:
<add verb="*" path="*.imu" type="Website.Handlers.ImageHandler, Website, Version=1.0.0.0, Culture=neutral" />
in the Website project I have a folder named Handlers which contains my ImageHandler class. It looks like this (I have removed the processrequest code)
using System;
using System.Globalization;
using System.IO;
using System.Web;
namespace Website.Handlers
{
public class ImageHandler : IHttpHandler
{
public virtual void ProcessRequest(HttpContext context)
{
//the code here never gets fired
}
public virtual bool IsReusable
{
get { return true; }
}
}
}
If I run my website and go to /something.imu it just returns a 404 error.
I am using Visual Studio 2008 and trying to run this on the ASP.Net development server.
I’ve been looking for several hours and had it working in a seperate empty website. So I don’t understand why it won’t work inside an existing website. There are no other references to the *.imu path btw.
I suspect that this has everything to do with the fact that you are using MVC, as basically it takes control of all incoming requests.
I suspect you will have to use the routing table, and possibly create a new routing handler. I haven’t done this myself but something like this might work:
and then the
ImageRouteHandlerclass will then return your customImageHttpHandler, although from looking at examples on the web it might be better to change that so it implementsMvcHandler, rather than straightIHttpHandler.Edit 1: As per Peter’s comment, you can also ignore the extension by using the
IgnoreRoutemethod: