On my Client Side I have an ajax call like below:
$.ajax({
url: "Controller/ListResult",
type: 'POST',
contentType: "application/json;charset=utf-8",
data: JSON.stringify({
Id: ObjectId,
SessionKey: sessionManager.getSessionKey()
}),
dataType: "json",
success: function (result) {
var test = results;
}
}
});
In the Controller I have a method like this :
[HttpPost]
public JsonResult ListResult(string Id, string SessionKey)
{
IBl biz = new BL();
var result = biz.GetResults(Id,SessionKey);
return Json(result);
}
The problem is the result that controller returns is an object which has Enum properties (with their string representation as value). However when it reaches the success function in the ajax call, the enums are no longer string representation, and instead, they have been converted to their int values. How can I avoid this? and keep the string representation on the javascript side.
sessionManager.getSessionKey()?ToString()on the enum properties (theJavascriptSerializerserializes enums to their numeric values and not their string representation)[JsonConverter(typeof(StringEnumConverter))]attribute on your properties