I have a routing problem and I can't figure out how to solve it.
There's a controller named "UsersController" and it contains 2 Post action functions:
public int PostFBLogin(User userObject){}
public void PostUpdateImgUrl(User userObject){}
When I make a POST request, I pass a JSON representation of "User" in the request body. If I comment out one of these functions, then it works fine. But when the both functions exist, whenever I try to make a request to each one of them, I get the following error:
"Multiple actions were found that match the request:
Int32 PostFBLogin(MestoryServer.Models.User) on type MestoryServer.Controllers.UsersController
Void PostUpdateImgUrl(MestoryServer.Models.User) on type MestoryServer.Controllers.UsersController"
I tried to solve it by putting the following routes in the routing tables:
RouteTable.Routes.MapHttpRoute(
name: "UserPostUpdateImgUrlAction",
routeTemplate: "api/users/PostUpdateImgUrl/",
defaults: new
{
controller = "users",
action = "PostUpdateImgUrl"
}
);
RouteTable.Routes.MapHttpRoute(
name: "UserPostFBLoginAction",
routeTemplate: "api/users/PostFBLogin/",
defaults: new
{
controller = "users",
action = "PostFBLogin"
}
);
But it didn't help.
After looking at lots of posts about routing tables on the internet, I'm not sure that it's even possible to have two actions which have the same signatures but different names.
Can anyone help?
Thanks, Edi.