【发布时间】:2015-07-17 14:00:15
【问题描述】:
我有几个名为 {WidgetName}WidgetController 的小部件控制器,例如样品小部件控制器。我需要创建一个路由来捕获对此类控制器的所有请求,并将它们与请求的控制器的名称和操作一起传递给一个公共控制器。
public class SampleWidgetController : Controller
{
public ActionResult Content()
{
...
}
}
public class CommonController : Controller
{
public ActionResult Content(string controllerName, string actionName)
{
// I want all requests to SampleWidget/Content to be passed here
// With controllerName = "SampleWidget" and actionName = "Content"
}
}
我可以创建一个自定义 RouteConstraint 以仅接受那些具有“Widget”后缀的控制器,但是我在定义路由本身时遇到了问题,该路由会将请求的控制器的名称和操作传递给公共控制器。
【问题讨论】:
-
你为什么要这样做..??你能说出目的吗..?
标签: c# asp.net-mvc asp.net-mvc-routing