There seems to be no action in your request ( /api/Login/KeyValue/CodeValue/UserValue/PasswordValue ). Try /api/Login/Get/KeyValue/CodeValue/UserValue/PasswordValue instead if you intend to use the first route.
If you want to be able to call it without the specified action, and the default is Get, you must specify the default action:
defaults: new { Key = UrlParameter.Optional, Code = UrlParameter.Optional, UserID = UrlParameter.Optional, Password = UrlParameter.Optional, Action = "Get" }
I have successfully tried this in an ASP.NET MVC 4 project (Visual Studio 2012 RC):
Create a LoginController with action:
public string Get(string Key, string Code, string UserID, string Password) { return Key + Code + UserID + Password; }
And the route display in Global.asax.cs:
RouteTable.Routes.MapHttpRoute(null, "api/{controller}/{Key}/{Code}/{UserID}/{Password}", new { Key = UrlParameter.Optional, Code = UrlParameter.Optional, UserID = UrlParameter.Optional, Password = UrlParameter.Optional, Action = "Get"});
If it does not work for you, perhaps another route will catch the request or the route will not be registered.
strmstn
source share