How do I use HTTP handlers for the selected paths and MVC handler for the rest?

I have an MVC2 application. I also have a set of ready-made HTTP handlers that are produced from System.Web.IHttpHandler. How to use them together?

I tried the following in web.config:

<system.webServer>
    <!--other stuff-->
        <handlers>
            <add name="MyCustomHandler" verb="GET" path="MySpecificPath*" type="CustomHandling.CustomHttpHandlerBase, CustomHAndlingAssembly"/>
            <add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
        </handlers>
</system.webServer>

but control never reaches my handler, and the MVC handler is used for all requests.

How to use my handler for one specific path and the MVC handler for all other paths?

+5
source share
1 answer

I believe that you need to ignore these specific paths from the route collection when starting the application. For instance,

routes.IgnoreRoute("MySpecificPath/{*pathInfo}");

UrlRoutingModule , http- IRouteHandler .

ASP.NET WebForms ASP.NET MVC . .

+2

All Articles