繁体   English   中英

ASP.NET MVC中的网址路由问题

[英]Url routing issue in asp.net mvc

我正在做一个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 ...

您可以将默认操作更改为Index也可以创建新的路线,例如

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

我只是通过将我的默认路由推到底部来工作,如asp.net-mvc默认路由的答案之一所述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM