有没有办法像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()。这可能吗?我这样做错了吗?