c# - Routing migration from ASP.NET WebAPI to ASP.NET Core WebAPI, ambiguous method issue -


i have existing asp.net webapi want migrate asp.net core webapi, facing issues in routing.

the apis consumed many clients , cannot change routes (or urls). have controller (say valuescontroller) 2 methods different parameters:

public async task<ienumerable<string>> get(int xid, int yid)

public async task<ienumerable<string>> get(int xid, int yid, int aid, int bid)

in current scenario (asp.net webapi), clients able call both methods on basis of different parameters like:

for calling method first, 1 can request url: http://localhost:4040/api/values?xid=1&yid=2 , second one, can request url: http://localhost:4040/api/values?xid=1&yid=2&aid=3&bid=4. , automatically decided current routing available asp.net webapi

but in case of asp.net core, if request same url, throws microsoft.aspnetcore.mvc.internal.ambiguousactionexception: multiple actions matched exception.

any possible solution without changing request call every client application?

if possible why doont make single function?? way think without disturbing other code i.e

    public async task<ienumerable<string>> get(int xid, int yid, int aid=0, int bid = 0) { if(aid>0 && bid>0) { //your second controller code here  return result } else { //your second controller code here  return result } } 

now both calls can handled in same function


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -