Sunday, 15 July 2012

c# - webapi error Multiple actions were found that match the request -



c# - webapi error Multiple actions were found that match the request -

i have accountcontroller has 2 actions here declarations:

httpresponsemessage postaccount([frombody] business relationship account) public httpresponsemessage postlogin([frombody]string email,[frombody] string pass)

running in fiddler, receiving error multiple actions found match request. im little confused on whats going on. should create 2 controllers login , register? standard practice.

you can have 1 parameter comes body in web api. if want multiple things in body, should wrap them in container class.

the error you're getting happening because have 2 actions start "post". can either create separate controllers, makes sense if you're posting different types of entities. or can utilize action-based routing , create route looks this:

config.routes.maphttproute("actionbased", "{controller}/{action}");

to distinguish between 2 actions when post.

c# asp.net-mvc asp.net-web-api

No comments:

Post a Comment