具有相同routeTemplate webAPI的MapHttpRoutes的几个处理程序

时间:2018-05-25 10:55:28

标签: c# asp.net-web-api asp.net-web-api-routing

是否可以使用相同的routeTemplate为不同的MapHttpRoutes设置多个处理程序? 例如:

config.Routes.MapHttpRoute(
    name: "TrainerUnconfirmedCandidatesApi",
    routeTemplate:
    "api/unconfirmed-candidates/{guid}",
    defaults: new { controller = "UnconfirmedCandidates", guid = RouteParameter.Optional },
    constraints: null,
    handler: trainerRouteHandler
);

config.Routes.MapHttpRoute(
    name: "AdminUnconfirmedCandidatesApi",
    routeTemplate:
    "api/unconfirmed-candidates/{guid}",
    defaults: new { controller = "UnconfirmedCandidates", guid = RouteParameter.Optional },
    constraints: null,
    handler: adminRouteHandlers
);

或者也许是这样:

config.Routes.MapHttpRoute(
    name: "AdminUnconfirmedCandidatesApi",
    routeTemplate:
    "api/unconfirmed-candidates/{guid}",
    defaults: new { controller = "UnconfirmedCandidates", guid = RouteParameter.Optional },
    constraints: null,
    handler: adminRouteHandlers, trainerRouteHandler
);

P.S。我知道这两个例子都不起作用。

0 个答案:

没有答案