【发布时间】:2018-08-23 07:26:32
【问题描述】:
在 ASP.NET MVC 中路由配置如下:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
我在 Controller 中使用[Route] 属性:
[Route("login")]
public ActionResult Login()
{
return View();
}
我可以同时使用/login 和Auth/Login 访问该页面。第二个链接显然来自默认路由,但我不希望该 URL 转到我的登录页面。
我该怎么做?
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-5 routing asp.net-mvc-routing