在ASP.NET MVC中支持 HttpHandler

写HttpHandler与ASP.NET WebForm基本没有什么不同。只是部署的时候需要注意,只在Web.config中注册还不行,需要在Global.asax.cs添加一条ignore规则:

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

            RouteTable.Routes.IgnoreRoute("{filename}.ashx");
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }

链接:

http://www.hanselman.com/blog/BackToBasicsDynamicImageGenerationASPNETControllersRoutingIHttpHandlersAndRunAllManagedModulesForAllRequests.aspx

原文地址:https://www.cnblogs.com/qkhh/p/3515348.html