Sending url params and POST body to a MVC 2 Controller
- by Luiggi
Hi, I'm having some issues trying to make a HTTP PUT (or POST) using WebClient against a MVC 2 controller. The exception is:
The parameters dictionary contains a null entry for parameter 'total'
of non-nullable type 'System.Int32' for method
'System.Web.Mvc.ActionResult Company(System.Guid, Int32, Int32, System.String)'
The controller action is:
[HttpPut]
public ActionResult Company(Guid uid, int id, int total, string url)
The route is:
routes.MapRoute(
"CompanySet",
"job/active/{uid}/company/{id}",
new { controller = "Job", action = "Company" }
);
As you may see, what I want is to send the 'uid' and 'id' parameters via url, but the 'total' and 'url' parameters as part of the PUT or POST body.
I've also tried to merge the latter parameters into a class (i.e., CompanySetMessage), doing it no longer raises an exception but I dont receive the values on the server side.
Any ideas? Thank you!