I have a controller named LoginController with a Get method with a signature of:
public string Get(string Key, string Code, string UserID, string Password)
I want to be be able to invoke it with a call similar to:
http://localhost:1234/api/Login/KeyValue/CodeValue/UserValue/PasswordValue
I cannot get this to work. If I invoke the call with:
http://localhost:1234/api/Login?Key=KeyValue&Code=CodeValueUserID=UserValue&Password=PasswordValue
The call is successful.
I've tried adding routes such as below to Global.asax
routes.MapHttpRoute(name: "Login", routeTemplate: "api/{controller}/{action}/{Key}/{Code}/{UserID}/{Password}",
defaults: new { Key = UrlParameter.Optional, Code = UrlParameter.Optional, UserID = UrlParameter.Optional, Password = UrlParameter.Optional });
or
routes.MapHttpRoute(name: "Login", routeTemplate: "api/{controller}/{Key}/{Code}/{UserID}/{Password}",
defaults: new { Key = UrlParameter.Optional, Code = UrlParameter.Optional, UserID = UrlParameter.Optional, Password = UrlParameter.Optional });
These do not seem to work. Where am I going wrong or is this even possible? I was able to do this in the RC version of WebApi with MVC3.