0
让我们说我有这样的主控制器在我的MVC应用程序:RouteArea和“多控制器类型中发现匹配的URL是”错误
[RouteArea("Blog")]
public class PageController : BaseAppController
{
}
[RouteArea]
// Called on mydomain/Blog
// and also called on mydomain/
public class BaseAppController : Controller
{
[Route]
public ActionResult Index()
{
return Content("this is the index file form the main controller");
}
}
,因为它的预期,我会得到在mydomain/Blog
Index
行动,但由于某种原因,我也在我的/
中得到它,这与我从另一个控制器获得的另一种观点相冲突。 我没有任何默认设置为我的任何根:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.LowercaseUrls = true;
routes.MapMvcAttributeRoutes(new CustomDirectRouteProvider());
}
任何想法是什么问题?
什么是CustomDirectRouteProvider? –
@AlexArt。在那里启用控制器继承。检查它在这里:http://stackoverflow.com/questions/19989023/net-webapi-attribute-routing-and-inheritance – Yar
@霍曼 - 根据评论下面的答案,许多人无法得到它的工作。此外,答案是** WebAPI **,而不是** MVC **。 – NightOwl888