Код: Выделить всё
ReturnResult ret = new() { Error = "" };
using var ms = new MemoryStream();
ChrtGraph.SaveImage(ms, ChartImageFormat.Png);
ret.Img = Convert.ToBase64String(ms.ToArray());
return System.Text.Json.JsonSerializer.Serialize(ret)
Код: Выделить всё
public class ReturnResult
{
public string? Img { get; set; }
public required string Error { get; set; } = "";
}
Код: Выделить всё
var form = $('#__AjaxAntiForgeryForm'),
token = $('input[name="__RequestVerificationToken"]', form).val(),
GetTextureChart = {};
GetTextureChart.Width = 943;
GetTextureChart.Height = 466;
$.ajax({
url: "Chart/GetTextureChart",
type: "POST",
data: JSON.stringify(JSON.stringify(GetTextureChart)),
contentType: "application/json; charset=utf-8",
dataType: "json",
headers: {
RequestVerificationToken: $(token).val()
},
success: function (response) {
var ret = JSON.parse(JSON.stringify(response));
if (ret.Error == "")
$("#chrtgraph").attr('src', 'data:image/png;base64,' + ret.Img);
else
$("#lblerr").text("Error " + ret.Error);
},
failure: function (response) {
$("#lblerr").text("fail " + response.responseText);
},
error: function (response) {
$("#lblerr").text("Error " + response.responseText);
}
});
Код: Выделить всё
Я просмотрел все и нашел разные вещи, такие как добавление в program.cs:< /p>
Код: Выделить всё
builder.WebHost.ConfigureKestrel(serverOptions =>
{
serverOptions.Limits.MaxResponseBufferSize = 100000;
});
Подробнее здесь: https://stackoverflow.com/questions/788 ... f-string-i