c# - ASP.NET Web Api 2 routing convention strange implementation -
we know web api 2 routing conventions , how can use following automatically map onto apicontroller types , actions:
config.routes.maphttproute( "default", "api/{controller}/{action}" ); public class abcdefghijklmnocontroller : apicontroller { public int test() { return 5; } }
this works expected, 5 when calling api/abcdefghijklmno/test. want create controller types don't explicitely end controller in end, combined custom controller discovery mechanism outlined in http://www.strathweb.com/2013/08/customizing-controller-discovery-in-asp-net-web-api/.
public class abcdefghijklmno : apicontroller { public int test() { return 5; } }
the crazy thing can value 5 route api/abcde/test, convention based routing doing chopping off the length of string "controller" type's name. apart extremely naive implementation web api 2, there way circumvent this?
Comments
Post a Comment