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 follow开发者_开发技巧ing 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?
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 .
精彩评论