c# - Asp.NET Web Api 2 Routing parameters -


i have following route:

 config.routes.maphttproute(                 name: "defaultapi",                 routetemplate: "api/{service_name}/{controller}/{id}",                 defaults: new { service_name = "identity", id = routeparameter.optional }             ); 

i want route work following pattern (service name should identity):

api/identity/{anycontroller}/{id} 

now accomplish changing route template

routetemplate: "api/identity/{controller}/{id}", 

but not able read "service_name" request.getroutedata(); since it's not named parameter.

is there simpler way this, rather creating actionfilter filter requests who's service name not "identity" in case.

you add route attribute above method affected. example,

[route("api/identity/{controller}/{id}", order = 1)] [httpget] public ihttpactionresult dosomethinghere(int id) {     // magic here } 

have @ article attribute routing in asp.net web api 2.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -