This project is read-only.

CreateResponse<> - how to use in MVC 4 RC

Topics: ASP.NET Web API
Jun 10, 2012 at 4:13 AM


 i have noticed that httprequestmessage<> , httpresponsemessage<> are not shipped with MVC 4 RC which were there as part of MVC4 beta.

i am trying to implement the action filter for model validation & got struck @ creating a response object & assign it to response message

Unable to build this piece of code :


 context.Response = context.Request.CreateResponse<JObject>(HttpStatusCode.BadRequest, errors);


ERROR is :

Error    2    'System.Net.Http.HttpRequestMessage' has no applicable method named 'CreateResponse' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.    ....\Projects\FWM\FWM\Filters\ValidationActionFilter.cs    32    36    FWM

Jun 18, 2012 at 9:46 PM

You need to type your errors variable as JObject instead of dynamic.

Daniel Roth