routes.IgnoreRoute("{handler}.ashx?{*path}", new { handler = @"image" });
</div>
<div>Just to be sure... Can you post your web.config (httpHandlers section) and global.asax.cs class?</div>
Item 1: Image path - no I don't think the path is ok. If I enter the complete path to the handler I get a controller error. (I'm using Dependency Injection, see below) Here's the html for the image tag:
<img src="ImageHandler.ashx?PhotoID=1&Size=M" alt="Photo Number 1" />
Just so you know, and this could be an issue, the location of the physical ashx file is: /Views/Shared/Imagehandler.ashx.
I did try adding the path to the img tag, but that didn't work either. No matter what I do, the handler does not get fired.
What does the routes.IgnoreRoute(...) do? It seems like it should ignore anything with this filename or extension. Is that not the case?
Here's something else that might help you, I'm using a Dependency Injector to handle the mapping to classes. Do you think I need to map this some how? I'm using the Microsoft.Practices.Unity container for the IoC. I'm not sure if this is part of the problem, but it might be.
Thanks for your help.
Here's my Global.asax class:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; using System.Configuration;
using Microsoft.Practices.Unity; using Microsoft.Practices.Unity.Configuration;
using PersonalKit.Mvc.Services; using PersonalKit.Mvc.Data; //using PersonalKit.Mvc.Core.HttpHandlers;using PersonalKit.Mvc.Web.Views.Shared;
namespace PersonalKit.Mvc.Web { public class MvcApplication : System.Web.HttpApplication { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
kahanu
Member
90 Points
147 Posts
Re: How to use a custom HttpHandler in MVC?
Sep 17, 2008 01:55 AM|LINK
Item 1: Image path - no I don't think the path is ok. If I enter the complete path to the handler I get a controller error. (I'm using Dependency Injection, see below) Here's the html for the image tag:
Here's my web.config httpHandlers section:
Just so you know, and this could be an issue, the location of the physical ashx file is: /Views/Shared/Imagehandler.ashx.
I did try adding the path to the img tag, but that didn't work either. No matter what I do, the handler does not get fired.
What does the routes.IgnoreRoute(...) do? It seems like it should ignore anything with this filename or extension. Is that not the case?
Here's something else that might help you, I'm using a Dependency Injector to handle the mapping to classes. Do you think I need to map this some how? I'm using the Microsoft.Practices.Unity container for the IoC. I'm not sure if this is part of the problem, but it might be.
Thanks for your help.
Here's my Global.asax class:
MVC Central
http://www.mvccentral.net