Sending url params and POST body to a MVC 2 Controller

Posted by Luiggi on Stack Overflow See other posts from Stack Overflow or by Luiggi
Published on 2010-05-25T03:35:08Z Indexed on 2010/05/25 3:41 UTC
Read the original article Hit count: 211

Filed under:
|
|
|
|

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!

© Stack Overflow or respective owner

Related posts about http

Related posts about url