Mvc 5支持传统的ashx链接

时间:2015-05-26 16:10:23

标签: c# redirect routing routes asp.net-mvc-5

有没有办法像MapRoute一样支持ashx链接?

例如我有这个

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "ashx",
            url: "test/redirect.ashx",
            defaults: new { controller = "Click", action = "Redirect" }
        );

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


    }

这不起作用,但我正在寻找的是,如果网址开始是www.example.com/test/redirect.ashx?foo=bar它会将我重定向到我的控制器ClickController.Redirect()。这可能吗?我这样做错了吗?

0 个答案:

没有答案