为什么在我的路线中使用* catchall我的路线不正确

时间:2019-07-09 14:13:48

标签: c# asp.net-mvc asp.net-core

当我在程序中使用* catchall时,路由不正确。

public void Configure(IApplicationBuilder应用程序,IHostingEnvironment env)         {

        app.UseMvc(routes =>
        {
            routes.MapRoute(
            name: "AdminArea",
            template: "{area:exists}/{controller=home}/{action=index}/{id?}");

            routes.MapRoute(
                name: "SimplifyAsdreaAdmin",
                template: "{controller=home}/{action=index}/{id:int?}/*Catchall");

        });
    }

当我在第二条路线中删除* catchall时,该路线会正确运行。但是当我需要去区域时放* catchall(例如:admin) 给我这个网址:https://localhost:44339/home/temping?area=Admin

有人知道为什么会发生这种情况吗?

1 个答案:

答案 0 :(得分:0)

您需要像其他路线参数.../{*catcahall}

一样用大括号括起来
相关问题