我有一个 MVC2 应用程序。我还有一组从 System.Web.IHttpHandler
派生的现成的 HTTP 处理程序。 .我如何一起使用它们?
我在 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>
但是控制永远不会到达我的处理程序,MVC 处理程序用于所有请求。
我如何将我的处理程序用于一个特定路径,并将 MVC 处理程序用于所有其他路径?
最佳答案
我相信您需要在应用程序启动时忽略路由集合中的那些特定路径。例如,
routes.IgnoreRoute("MySpecificPath/{*pathInfo}");
否则 UrlRoutingModule将与路由匹配,然后 http 处理程序将通过
IRouteHandler
定位对于那条路线。见 this article有关将 ASP.NET WebForms 与 ASP.NET MVC 混合的更多信息。
关于.net - 如何将我的 HTTP 处理程序用于选定的路径,并将 MVC 处理程序用于其余路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7596303/