asp.net mvc - Modify the key/value pair of a ModelState MVC attribute -
is there way modify key of modelstate attribute? receive following json response:
{"message":"the request invalid.", "modelstate": { "supplier.supplierwarehouses[2].location":["location name long, maximum 50 characters"] } }
i want modify supplier.supplierwarehouses[2].location more simple supplierlocation.
is there way directly in model? current model is:
public class supplierwarehousemetadata { [stringlength(50,errormessage="location name long, maximum 50 characters")] public string location { get; set; } }
no, because isn't modelstate
. post value has name because that's modelbinder needs in order bind correctly appropriate property on model on post. if modify name, value no longer bind.
that said, goal here anyways? if you're concerned what's coming in json, return custom instead of dumping modelstate
.
Comments
Post a Comment