Sunday, 15 September 2013

allow multiple get methods in same controller web api asp.net -



allow multiple get methods in same controller web api asp.net -

public class usercontroller : baseapicontrollerauth { public arraylist getpermissions() { come in code here } public usermodelcollection get() { } public usermodelcollection get(fromuri id) { } }

my webapiconfig file route is

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

1.api/user/ working 2.api/user/123 working 3.api/usr/permissions gives error multiple actions found match request

how can solve ???

why not utilize web api 2 attributes routing instead of traditional one?

you can next using attribute routing:

[httpget] [route("obtaindata")] public async task<ihttpactionresult> obtaindata(string input){} [httpget] [route("obtaindata2")] public async task<ihttpactionresult> obtaindata2(string input){}

asp.net-web-api

No comments:

Post a Comment