【问题标题】:How do I figure out why MVC5 attribute routing isn't being added to the routing table?我如何弄清楚为什么没有将 MVC5 属性路由添加到路由表中?
【发布时间】:2015-04-17 14:33:09
【问题描述】:

我有一些属性路由由于某种原因没有被添加到路由表中。

我找到了这个ASP MVC 5 Attribute routing not registering routes

但这不是我的解决方案。有没有办法找出为什么没有添加路线?

谢谢,

约翰

【问题讨论】:

  • 我的问题是在将路由添加到路由表期间发生的,由于某种原因,某些路由没有被添加。我认为这只会显示路由表的状态,对吗?
  • 是的,你能发布你的代码吗?
  • 奇怪的是,有些路由有效,而有些则无效。我将努力将应用程序剥离到一个基本的故障点。

标签: asp.net-mvc asp.net-mvc-5 asp.net-mvc-routing


【解决方案1】:

你在打电话给MapAttributeRoutes吗?

public static void RegisterRoutes(RouteCollection routes) 
{    
    // See http://github.com/mccalltd/AttributeRouting/wiki for more options.
    // To debug routes locally using the built in ASP.NET development server, go to /routes.axd

    routes.MapAttributeRoutes();
}

【讨论】:

  • 有些路线有效,有些则无效。我打电话给routes.MapMvcAttributeRoutes();
猜你喜欢
  • 2016-01-12
  • 2014-04-15
  • 2014-04-18
  • 2016-09-04
  • 1970-01-01
  • 2016-05-23
  • 1970-01-01
  • 2019-08-21
  • 1970-01-01
相关资源
最近更新 更多