我正在研究AspNetCore中的web应用程序,并试图通过ajax调用从我的控制器获取数据。Ajax获取返回ERR_SPDY_PROTOCOL_ERROR
这里是我的API:
[HttpGet]
public async Task<IActionResult> GetPackWithAllCards(int? packId)
{
if (packId == null)
{
return Json("An error has occured");
}
else
{
var pack = await _context.Packs
.Include(p => p.TagPacks)
.ThenInclude(tp => tp.Tag)
.Include(p => p.CardPacks)
.ThenInclude(cp => cp.Card)
.ThenInclude(c => c.FaceCards)
.ThenInclude(fc => fc.Face)
.ThenInclude(fc => fc.Template)
.Include(p => p.CardPacks)
.ThenInclude(cp => cp.Card.FaceCards)
.ThenInclude(fc => fc.Face.Image)
.Include(p => p.CardPacks)
.ThenInclude(cp => cp.Card.FaceCards)
.ThenInclude(fc => fc.Face.Sound)
.SingleOrDefaultAsync(m => m.PackId == packId);
if (pack == null)
{
return Json("An error has occured");
}
return Ok(pack);
}
}
和我的Ajax调用:
$.get("/pack/GetPackWithAllCards", { packId: pack.packId }, function (pack) {
alert(pack);
});
我的错误是百达一样的,我得到 “无法加载资源:净:: ERR_SPDY_PROTOCOL_ERROR” 与状态= 0
我的api正确地返回一个包,但我的ajax调用没有得到它。
遇到此链接,可能会有帮助:https://www.techsupportall.com/fix-err_spdy_protocol_error-permanently/和https://zenguard.zendesk.com/hc/en-us/articles/204423722-Chrome -error-ERR-SPDY-PROTOCOL-ERROR- –
它不起作用 – Elykx