在 ASP.NET Core 6 中使用 TempData 时出现 ERR_HTTP2_PROTOCOL_ERROR

问题描述 投票:0回答:1

当我不使用 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");

有什么想法吗??

asp.net-core
1个回答
0
投票

就我而言,将此代码添加到 Program.cs 解决了问题:

builder.Services.AddControllers().AddJsonOptions(options =>
{
    options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
    options.JsonSerializerOptions.WriteIndented = true;
});
© www.soinside.com 2019 - 2024. All rights reserved.