Tell the simulation that the MVC action parameter is JSON

I use the upload control to send the file to JsonResult, but I also send the JSON string as the second parameter. All this is sent using Content-Type: multipart / form-data;

[HttpPost]
public JsonResult UploadDocument(HttpPostedFileBase file, DocumentViewModel model)
{ ... }

I know that MVC is able to bind directly to the viewmodel if the content type is set to application / json, but I don't think it is possible for me in this case.

Is there any way to get MVC to automatically bind my hosted json string to the model?

0
source share
2 answers

Since I was unable to change the type of content, I found this blog exactly what I needed.

"... () json-. json..."

http://ishwor.cyberbudsonline.com/2012/07/fun-with-aspnet-mvc-3-custom-json-model-binder.html

0

. JSON, , , . JSON, : multipart/form-data. , - , , .

+2

All Articles