如何设置不使用属性路由路由的控制器方法

Her*_*nan 2 asp.net-mvc-routing attributerouting asp.net-mvc-5

我在控制器级别应用了一个路由属性,但是我希望将一个动作排除在路由之外.没有覆盖,但完全排除了路线.怎么能实现这一目标?

比方说我有:

[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() { ... }
}
Run Code Online (Sandbox Code Playgroud)

我希望内部不要被路由.

我原本期望找到[DoNotRoute]或[Ignore]属性,但我没有找到类似的东西.

Max*_*oro 12

使用[NonAction]属性:

[NonAction]
public void Internal() { ... }
Run Code Online (Sandbox Code Playgroud)