UPDATE
a spnet:MaxJsonDeserializerMembers <appSettings> web.config, 2147483647, Int32.
<configuration>
<appSettings>
<add key="aspnet:MaxJsonDeserializerMembers" value="2147483647" />
</appSettings>
</configuration>
, .
. , . , , json, .
@Flxtr:
OLD
, FormData
:
function getDataForm() {
var data = new FormData();
var files = fileUploader.get(0).files;
if (files.length > 0) {
data.append("File", files[0]);
}
data.append("ImagePath", "");
data.append("Id", ImageId);
data.append("Name", txtName.val().trim());
data.append("Description", txtDescription.val().trim());
return data;
}
function save(data) {
$.ajax({
type: "POST",
url: "/Files/SaveImage",
contentType: false,
processData: false,
data: data,
success: function (response) {
if (response.success) {
$.showMessage(messages.NAME, messages.SUCCESS, "success");
closeForm();
Files.ImageList.gridImages.ajax.reload();
}
else {
$.showMessage(messages.NAME, response.message, "error");
};
btnSave.button('reset');
},
error: function (request, status, exception) {
$.showMessage(messages.NAME, exception, "error");
btnSave.button('reset');
}
});
};
-:
<httpRuntime targetFramework="4.6.1" maxRequestLength="65536"/>
:
<system.web>
<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1" maxRequestLength="65536"/>
<customErrors mode="RemoteOnly">
<error statusCode="401" redirect="/Error/401" />
...
<error statusCode="411" redirect="/Error/411" />
</customErrors>
</system.web>
processData false ajax:
$.ajax({
url: "/Security/SavePermissions",
type: "POST",
processData: false,
contentType: "application/json; charset=utf-8",
data: JSON.stringify(pStrPermissions),
success: function (response) {
if (response.success) {
panel.showAlert("Permisos", "Se han actualizado correctamente los permisos.", "success");
resetForm();
}
else {
$.showMessage("Permisos", response.message, "error");
};
},
error: function (request, status, exception) {
$.showMessage("Permisos", exception, "error");
}
});
. , , - .
, :
function savePermissions(pLstObjPermissions) {
$.ajax({
url: "/Security/SavePermissions",
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ pStrPermissions: JSON.stringify(pLstObjPermissions)}) ,
success: function (response) {
if (response.success) {
panel.showAlert("Permisos", "Se han actualizado correctamente los permisos.", "success");
resetForm();
}
else {
$.showMessage("Permisos", response.message, "error");
};
},
error: function (request, status, exception) {
$.showMessage("Permisos", exception, "error");
}
});
};
:
public ActionResult SavePermissions(string pStrPermissions)
{
var lLstObjResult = new Dictionary<string, object>();
try
{
SecurityFactory.GetPermissionService().UpdateList(JsonConvert.DeserializeObject<IList<Permission>>(pStrPemissions));
lLstObjResult.Add(MESSAGE, "Registro guardado exitosamente");
lLstObjResult.Add(SUCCESS, true);
}
catch (Exception e)
{
lLstObjResult.Add(MESSAGE, e.Message);
lLstObjResult.Add(SUCCESS, false);
}
return Json(lLstObjResult, JsonRequestBehavior.AllowGet);
}
I know this is not the best way, but it works until something better appears.
If you have a better way to solve this problem, share it.