【发布时间】:2016-03-05 07:46:25
【问题描述】:
我想知道如何在 MVC.net 4 中有特定的地址 我的 Web 应用程序中有 3 种 url 类型 1-www,site.com/rss.xml 2-www.site.com/amir(这种类型的地址是为我的用户保留的,我想输入我网站的用户名,以便为我的每个用户创建个人资料地址) 3-www.site.com/article/detail/1
我的 RouteConfig 文件如下所示
routes.MapRoute(
name: "RSS_route", // Route name
url: "rss.xml", // URL with parameters
defaults: new { controller = "Common", action = "RSS", area = "" } // Parameter defaults
, namespaces: new[] { "Clinic.WebUI.Controllers" }
);
routes.MapRoute(
name: "Doctor",
url: "{docname}",
defaults: new { controller = "Doctor", action = "Doctor", docname = "test" }
, namespaces: new[] { "Clinic.WebUI.Controllers" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
, namespaces: new[] { "Clinic.WebUI.Controllers" }
);
routes.MapRoute(
name: "Article",
url: "{controller}/{action}/{id}/{subject}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional, subject = UrlParameter.Optional }
, namespaces: new[] { "Clinic.WebUI.Controllers" }
);
但问题是所有这 3 种 url 类型都无法访问,只有第 2 种有效 如果有人可以在这方面帮助我,我会很高兴
【问题讨论】:
标签: c# asp.net asp.net-mvc asp.net-mvc-4 asp.net-mvc-routing