Blog on software engineering
Custom IHttpHandler 404 not found in .NET Framework 4.7.2

Custom IHttpHandler 404 not found in .NET Framework 4.7.2

 

When you add a custom IHttpHandler to your ASP .NET Framework 4.7.2 project in a root folder like /Handlers/MyHandler.ashx and you access the url /Handlers/MyHandler.ashx, this handler will be executed,

But if you want this handler to be executed on another path, you will have to register the custom IHttpHandler.

 

In my case on IIS 10 with application pool in integrated mode (Managed Pipeline Mode = Integrated):

<system.webServer>
  ...
  <handlers>
    ...
    <add name="DownloadFile" verb="*" path="Helpers/DownloadFile.ashx" type="My.Custom.NameSpace.MyHandler, My.Assembly " resourceType="Unspecified" />
  </handlers>
</system.webServer>

 

But if you are also using MVC routing, you will have to ignore this route in the MVC routing:

 

public static void RegisterRoutes(RouteCollection routes)
{
            routes.IgnoreRoute("Handlers/MyHandler.ashx");

 

 

 

Solution

https://stackoverflow.com/questions/2858738/problem-mapping-httphandler-http-error-404-not-found/5247330

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.