当我不使用 TempData 时,页面工作正常,但当我使用它时,出现以下错误。
This site can’t be reachedThe webpage at https://localhost:44332/Home/UploadFile might be temporarily down or it may have moved permanently to a new web address.
ERR_HTTP2_PROTOCOL_ERROR
这是控制器的代码
TempData["Response"] = responseString;
return RedirectToAction("Index");
有什么想法吗??
就我而言,将此代码添加到 Program.cs 解决了问题:
builder.Services.AddControllers().AddJsonOptions(options =>
{
options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
options.JsonSerializerOptions.WriteIndented = true;
});