sha*_*oth 5 .net asp.net iis asp.net-mvc httphandler
我有一个MVC2应用程序.我还有一组可用的HTTP处理程序System.Web.IHttpHandler.我如何一起使用它们?
我在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>
Run Code Online (Sandbox Code Playgroud)
但控件永远不会到达我的处理程序,MVC处理程序用于所有请求.
如何将处理程序用于一个特定路径,将MVC处理程序用于所有其他路径?
我相信您需要忽略应用程序启动中的路由集合中的那些特定路径。例如,
routes.IgnoreRoute("MySpecificPath/{*pathInfo}");
Run Code Online (Sandbox Code Playgroud)
否则,UrlRoutingModule将与路由匹配,然后 http 处理程序将通过IRouteHandler该路由定位。
有关将 ASP.NET WebForms 与 ASP.NET MVC 混合的详细信息,请参阅本文。