【问题标题】:Url routing issue in asp.net mvcasp.net mvc 中的 URL 路由问题
【发布时间】:2010-05-19 03:03:28
【问题描述】:

我正在从我的家庭控制器执行return RedirectToAction("Index", "Clients");....很好,但我的 url 看起来像http://localhost:1115/Clients/Index...如何从 asp.net mvc 中的 url 中删除索引?任何建议....

我的路线,

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

        routes.MapRoute(
            "Registrations",                                             
            "{controller}/{action}/{id}",                           
            new { controller = "Registration", action = "Create", id = "" }    
        );
        routes.MapRoute(
            "Clients",                                              
            "Clients/{action}/{id}",                           
            new { controller = "Clients", action = "Index", id = "" }  
        );
    }

但它似乎仍然没有从我的网址中删除 index...

【问题讨论】:

    标签: asp.net-mvc indexing url-routing action


    【解决方案1】:

    您可以将默认操作更改为Index 或创建一个新路由,例如

    routes.MapRoute(
                "Clients",                                             
                "Clients/{action}/{id}",                           
                new { controller = "Clients", action = "Index", id = "" }    
            );
    

    【讨论】:

      【解决方案2】:

      正如asp.net-mvc default route 的答案之一所述,我只需将我的默认路由推到底部即可使其正常工作

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-07-03
        • 2011-11-11
        • 1970-01-01
        • 2013-11-13
        相关资源
        最近更新 更多