Pages

Banner 468 x 60px

 

Tuesday, 4 September 2012

Send multiple GET,POST Request in MVC

Go from this:
  config.Routes.MapHttpRoute(
"API Default",
 "api/{controller}/{id}",
 new { id = RouteParameter.Optional
 });  
To this:
  config.Routes.MapHttpRoute(
"API Default", 
"api/{controller}/{action}/{id}",
new { id = RouteParameter.Optional 
});  
Hence, you can now specify which action (method) you want to send your HTTP request to.
  public bool PostCreateUser(CreateUserCommand command)  {return true;  }  
  public bool PostMakeBooking(MakeBookingCommand command)  { return true;  }  
I tried this in a self hosted WEB API service application and it works like a charm :)

No comments:

Post a Comment