【问题标题】:why use *catchall in my route my routing isnt true为什么在我的路由中使用 *catchall 我的路由不是真的
【发布时间】:2019-11-19 03:05:35
【问题描述】:

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

public void Configure(IApplicationBuilder app, 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 (例如:管理员) 给我这个网址:https://localhost:44339/home/temping?area=Admin

有人知道为什么会这样吗?

【问题讨论】:

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


    【解决方案1】:

    你需要像其他路由参数.../{*catcahall}一样用大括号括起来

    【讨论】:

      猜你喜欢
      • 2021-02-28
      • 2013-11-26
      • 2018-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-26
      • 1970-01-01
      相关资源
      最近更新 更多