MVC路由前缀BUG与否

时间:2017-10-27 12:57:25

标签: asp.net-mvc url-routing

我发现奇怪的MVC路由前缀行为,我无法弄清问题是什么。 给出以下简单代码:

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

        routes.MapMvcAttributeRoutes();

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

[RoutePrefix("root/{input:alpha}/leaf")]
public class RouteController : Controller
{

    [HttpGet]
    [Route(Name = "name")]
    public ActionResult Index(string input)
    {
        return new HttpStatusCodeResult(200, input);
    }
}

当我发送以下请求时:

http://localhost:49637/root/COT/leaf = SUCCESSFUL
http://localhost:49637/root/CON/leaf = SERVER ERROR (404 The resource cannot be found.)

只有三个不起作用的字母是" CON"。为什么?

此致

0 个答案:

没有答案