within project have 2 versions of api. post understand custom control selector needs writing get different versions (as webapi looks controller name match , ignores namespaces in).
this works ok , can make calls different versions.
however, utilise new data attribute routing web api 2 , when using customer control selector not handle routing correctly.
the routing data attributes using follows.
(the v01 differs between versions can v02)
[route("api/v01/enumeration/{type}/{subtype}")]
this can contain additional query string params @ end well
[route("api/v01/user/readbyreference")]
this takes query string of ?id=email|email.domain.com
the code customer control selector can found here
i can see issue getroutevariable
needed namespace part , controller, wondering if else has had , if have way around it.
i looking if find update on here if have please let me know.
thanks
mark
after bit of digging have found out attribute routing goes via different path.
so handle attribute routing in getroutevariable
need grab ms_subroutes
values , perform needed action on result namespace , controller. below needs tidying @ least gives idea of done process data attribute routing in custom control selector
var subroutes = (ienumerable<ihttproutedata>)routedata.values["ms_subroutes"]; var routebreakdown= subroutes.first().route.routetemplate.split('/'); if (name == "namespace") { return (t)(object)routebreakdown[1]; //namespace } else if (name == "controller") { return (t)(object)routebreakdown[2]; //controller }
cheers mark
Comments
Post a Comment