【发布时间】:2014-04-20 04:36:21
【问题描述】:
我已在控制器级别应用了路由属性,但我想从路由中排除操作。不覆盖但完全排除路线。如何实现?
假设我有:
[RoutePrefix("promotions")]
[Route("{action=index}")]
public class ReviewsController : Controller
{
// eg.: /promotions
public ActionResult Index() { ... }
// eg.: /promotions/archive
public ActionResult Archive() { ... }
// eg.: /promotions/new
public ActionResult New() { ... }
// eg.: /promotions/edit/5
[Route("edit/{promoId:int}")]
public ActionResult Edit(int promoId) { ... }
public void Internal() { ... }
}
并且我希望内部不被路由。
我本来希望找到 [DoNotRoute] 或 [Ignore] 属性,但我没有找到类似的东西。
【问题讨论】:
-
你是手动路由Internal,还是根本就不是动作?
-
根本不是动作。它是一个公共方法,位于基本控制器及其接口的实现中。
标签: asp.net-mvc-routing asp.net-mvc-5 attributerouting