Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jun 21, 2012 03:12 AM by JohnChapmanSc
Member
1 Points
2 Posts
Jun 20, 2012 06:07 PM|LINK
Calls make it to the correct method in my Controller but the parameter is null when I call with this: http://localhost:54668/api/Policy/GetPolicy/0001
However it has a value when I call this: http://localhost:54668/api/Policy?policyNumber=0001 What am I missing?
Global.asax: ================================================================== RouteTable.Routes.MapHttpRoute( name: "PolicyApiControler", routeTemplate: "api/Policy/{action}/{policyNumber}", defaults: new { controller = "PolicyController", policyNumber = RouteParameter.Optional });
Controller ====================================================================== public HttpResponseMessage<Policy> GetPolicy(string policyNumber) { /* Code */ return new HttpResponseMessage<Policy>(p); }
16 Points
4 Posts
Jun 21, 2012 12:42 AM|LINK
In the call to MapHttpRoute(), try setting controller = "Policy" instead of "PolicyController".
Jun 21, 2012 03:12 AM|LINK
Perfect thanks.
JohnChapmanS...
Member
1 Points
2 Posts
Parameter null when Controller called
Jun 20, 2012 06:07 PM|LINK
Calls make it to the correct method in my Controller but the parameter is null when I call with this: http://localhost:54668/api/Policy/GetPolicy/0001
However it has a value when I call this: http://localhost:54668/api/Policy?policyNumber=0001 What am I missing?
Global.asax:
==================================================================
RouteTable.Routes.MapHttpRoute(
name: "PolicyApiControler",
routeTemplate: "api/Policy/{action}/{policyNumber}",
defaults: new { controller = "PolicyController", policyNumber = RouteParameter.Optional });
Controller
======================================================================
public HttpResponseMessage<Policy> GetPolicy(string policyNumber)
{ /* Code */
return new HttpResponseMessage<Policy>(p);
}
art.dumas
Member
16 Points
4 Posts
Re: Parameter null when Controller called
Jun 21, 2012 12:42 AM|LINK
In the call to MapHttpRoute(), try setting controller = "Policy" instead of "PolicyController".
JohnChapmanS...
Member
1 Points
2 Posts
Re: Parameter null when Controller called
Jun 21, 2012 03:12 AM|LINK
Perfect thanks.