c# - Another one about multiple matching actions in ASP.NET Web Api 2 -


i've read these questions:

multiple actions found match request: webapi
web api routing - multiple actions found match request multiple actions found match request web api?

and i've updated routeconfig follows:

routes.maproute(     name: "receipt",     url: "api/{controller}/{action}/{id}",     defaults: new { controller = "receipt", action = "post", source = urlparameter.optional } ); 

creating new route map hasn't helped fix problem in slightest

here's relevant functions in controller:

public httpresponsemessage post ([frombody]createreceiptviewmodel source) {     try     {         // stuff happens here     }     catch (exception ex)     {         // went wrong, save exception data database         // recorderror(ex, "post receipt", "receiptcontroller/post");     } }  //public void recorderror(exception ex, string action = "", string origin = "pocketplooto api") //{ //    error error = new error //    { //        date = datetime.now, //        detail = ex.tostring(), //        message = ex.message, //        origin = origin, //        stacktrace = ex.stacktrace, //        action = action //    };  //    db.errors.add(error); //    db.savechanges(); //} 

the function large feel impractical include here.

interestingly enough, while recorderror commented, post happens fine.

if uncomment it, error occurs (my test environment doesn't allow me see in format other json, apologies inconvenience):

"message":"an error has occurred.",
"exceptionmessage":"multiple actions found match request: \r\npost on type webapiservice.controllers.receiptcontroller\r\nrecorderror on type webapiservice.controllers.receiptcontroller",
"exceptiontype":"system.invalidoperationexception",
"stacktrace":" @ system.web.http.controllers.apicontrolleractionselector.actionselectorcacheitem.selectaction(httpcontrollercontext controllercontext)\r\n @ system.web.http.controllers.apicontrolleractionselector.selectaction(httpcontrollercontext controllercontext)\r\n @ system.web.http.apicontroller.executeasync(httpcontrollercontext controllercontext, cancellationtoken cancellationtoken)\r\n @ system.web.http.dispatcher.httpcontrollerdispatcher.d__1.movenext()"

unfortunately don't understand stack trace , since there isn't duplicate actions here, can't begin guess web api doing or why having problem in controller problem.

can provide clarity on stack trace means , why function problem?

if private methods need not accessed outside set [nonaction] attribute on methods.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -