web api get route template from inside handler

后端 未结 4 1493
春和景丽
春和景丽 2021-01-12 06:05

I searched a lot before putting the questions here but the more I search the more confused I get.

So I have created an handler and I am trying to get the route like

4条回答
  •  星月不相逢
    2021-01-12 06:17

    The Web Api still has a lot to improve. It was tricky to find a way to get this working and I just hope this saves other guys from spending all the time I did.

     var routeTemplate = ((IHttpRouteData[]) request.GetConfiguration().Routes.GetRouteData(request).Values["MS_SubRoutes"])
                                        .First().Route.RouteTemplate;
    

提交回复
热议问题