C# MVC5URL.将RouteValue显示为QueryString的操作

C# MVC5URL.将RouteValue显示为QueryString的操作,c#,asp.net-mvc,asp.net-mvc-routing,C#,Asp.net Mvc,Asp.net Mvc Routing,我试图创建一个使用路由值而不是查询字符串的自定义路由,不知道为什么它们只显示为url操作中的查询字符串 这是我的区域注册中的路线设置 context.MapRoute( "Member_Bank_Account", "Member/{controller}/{bank}/{account}", new { action = "Index" }, new[] { "Application.Web.Areas.Member.Controllers" }); context.Ma

我试图创建一个使用路由值而不是查询字符串的自定义路由,不知道为什么它们只显示为url操作中的查询字符串

这是我的区域注册中的路线设置

context.MapRoute( "Member_Bank_Account", "Member/{controller}/{bank}/{account}", new { action = "Index" }, new[] { "Application.Web.Areas.Member.Controllers" }); context.MapRoute( “会员银行账户”, “成员/{controller}/{bank}/{account}”, 新建{action=“Index”}, 新[]{“Application.Web.Areas.Member.Controllers”}); 当我从html调用它时

<a href="@Url.Action("Index", "Bank", new {area = "Member", bank = "MyBank", account = "Primary"})" class="btn btn-primary btn-sm">Primary</a> 两个URL似乎都工作正常

我可以去:

  • http://localhost/Member/Bank/MyBank/Primary
  • http://localhost/Member/Bank?bank=MyBank&account=Primary
但是html链接总是显示查询字符串,不确定我做错了什么


您知道如何将其显示为路由而不是查询字符串吗?

如何定义控制器操作?哪个版本的MVC?我在这个演示项目中看到了您想要的链接,它是MVC5:Action只是一个典型的设置,就像这样。。。“公共操作结果索引(字符串银行、字符串帐户){return this.View();}”它正在使用MVC v5.2.0提供答案还是删除问题?这是有效的点击诱饵。。。