【转】[C#] 从 ashx 升级到 MVC

让原有页面不受影响的做法是:
public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        // 添加文件类型的排除
        routes.IgnoreRoute("{*allashx}", new { allashx = @".*\.ashx(/.*)?" });
        routes.IgnoreRoute("{*allajax}", new { allajax = @".*\.ajax(/.*)?" });

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { action = "Index", id = UrlParameter.Optional }
        );
    }
}

然后对比原来的 Web.Config 文件、Bin 目录文件,做成更新包即可。

posted on 2025-01-15 10:16  z5337  阅读(20)  评论(0)    收藏  举报