asp.net web api2 - Web Api Routing with 404 response IHttpActionResult -


i trying below routes work having issue. route api/user/name works fine; result "whats up".

however, route api/user/register results in 404.

private void configurewebapi(httpconfiguration config) {     config.maphttpattributeroutes();      var jsonformatter = config.formatters.oftype<jsonmediatypeformatter>().first();     jsonformatter.serializersettings.contractresolver = new camelcasepropertynamescontractresolver(); }  

the controller:

using system.web.http; using angular.data.iservices; using angular.data.modals;  namespace angular.api.controllers {     [routeprefix("api/user")]     public class usercontroller : apicontroller     {         private iuserservice _userservice;          [route("name")]         [httpget]         public string name()         {             return "whats up";         }           [route("register")]         public ihttpactionresult register(user usr, string password)         {             _userservice.registeruser(usr, password);              //var response = request.createresponse<user>(httpstatuscode.created, usr);              //string uri = url.link("register", new { id = usr.id });             //response.headers.location = new uri(uri);             return ok("response");         }     } } 

are passing values usr , password in request? if not, that's problem. want make single model contains of data need registration, rather splitting usr , password 2 parameters.

for example, try changing method signature this:

[route("register")] [httpget] public ihttpactionresult register(string username, string password) 

then visit api/user/register/?username=test&password=pwd in browser , see if works.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -