Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have an MVC2 application. I also have a set of ready HTTP handlers that derive from System.Web.IHttpHandler. How do I 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>

yet control never reaches my handler and MVC handler is used for all requests.

How do I use my handler for one specific path and MVC handler for all other paths?

like image 523
sharptooth Avatar asked Nov 04 '22 13:11

sharptooth


1 Answers

I believe that you need to ignore those specific paths from routes collection in application start. For example,

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

Otherwise UrlRoutingModule will match with the route and then http handler will be located via IRouteHandler for that route.

See this article for more info about mixing ASP.NET WebForms with ASP.NET MVC .

like image 136
VinayC Avatar answered Nov 14 '22 03:11

VinayC