I have a controller where my PUT method uses multipart / form-data as the content type, and so I get the JSON and mapped class this way inside the controller.
Is it possible to test this model for annotations that I wrote in the model class while inside the controller?
public class AbcController : ApiController
{
public HttpResponseMessage Put()
{
var fileForm = HttpContext.Current.Request.Form;
var fileKey = HttpContext.Current.Request.Form.Keys[0];
MyModel model = new MyModel();
string[] jsonformat = fileForm.GetValues(fileKey);
model = JsonConvert.DeserializeObject<MyModel>(jsonformat[0]);
}
}
I need to check the " model " inside the controller. FYI, I added annotations to MyModel ().
source
share