Home/ASP.NET Forums/General ASP.NET/MVC/How to use a custom HttpHandler in MVC?

How to use a custom HttpHandler in MVC? [Answered]RSS

12 replies

Last post Feb 12, 2010 05:16 PM by N!cky

King Wilder
MVC Central
http://www.mvccentral.net
  • maartenba

    maartenba

    Member

    150 Points

    76 Posts

    Re: How to use a custom HttpHandler in MVC?

    Sep 17, 2008 07:13 AM|maartenba|LINK

    Can you try putting the handler in the root of the website?
    Visit my blog at http://blog.maartenballiauw.be

    Order my book ASP.NET MVC 1.0 Quickly via http://www.packtpub.com/asp-net-model-view-controller-1-0-quickly/book
  • kahanu

    kahanu

    Member

    62 Points

    146 Posts

    Re: How to use a custom HttpHandler in MVC?

    Sep 18, 2008 05:35 PM|kahanu|LINK

    maartenba

    Can you try putting the handler in the root of the website?

     

    That didn't work either.  I think it might have something to do with the Dependency Injection I'm using. 

    I'll keep looking.  I'm determined to figure this out!  [:)]

    Thanks.

    King Wilder
    MVC Central
    http://www.mvccentral.net
  • ranaian

    ranaian

    None

    0 Points

    4 Posts

    Re: How to use a custom HttpHandler in MVC?

    Aug 07, 2009 01:46 AM|ranaian|LINK

    FYI:

    I had this same problem and just solved it by adding an IgnoreRoute:

    public static void RegisterRoutes(RouteCollection routes)
    
    
    {
    
    
             routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
    
             routes.IgnoreRoute("Custom.sfx");
    
    
    }

    Provided classic/integration httpHandlers/handlers is setup properly and no authentication is blocking you it should be good to go.



  • N!cky

    N!cky

    Member

    10 Points

    41 Posts

    Re: How to use a custom HttpHandler in MVC?

    Feb 12, 2010 05:16 PM|N!cky|LINK

    I was up against this problem last night, and here is how I solved it

    I added this to my Global.asax file, before I defined my routes :

    routes.IgnoreRoute("{filename}.ashx");


    I added this to my <httpHandlers> node in my web config:

    <add verb="*" path="*ImgHandler.ashx" type="AMSignsUI.Views.Shared.ImgHandler, AMSignsUI"/>

    where : AMSignsUI.Views.Shared = the namespace in which I created the handler

    and AMSignsUI = my application/project name

    I added this to my <handlers> node in <system.webServer>

    <add name="ImgHandler" path="*ImgHandler.ashx" verb="*" type="AMSignsUI.Views.Shared.ImgHandler, AMSignsUI"/>


    Everything worked fine after I completed these steps. Note, the last step applies only if you are using IIS7

    Have a smile :)
  • ‹ Previous Thread|Next Thread ›