?Briella 2018-11-05 16:12 采纳率: 0%
浏览 36

asp.net核心ajax获取

I am making a simple jquery ajax get request. The first request works great. However, any subsequent returns the error 431 (Request Header Fields Too Large). It seems asp.net core is adding the headers that are quite large (see pic)

How do I resolve this issue?

Thanks in advance for the help![enter image description here]1

  • 写回答

1条回答 默认 最新

  • weixin_33728268 2018-11-05 20:01
    关注

    By default, TempData uses a cookie-based provider, which means each piece of data you add goes out as a cookie. It looks like you've added so much here that the header is now too large. The easiest solution is to use session state as a TempData provider, instead. Then, you'll just have one session cookie going out, regardless of how much data you set in TempData. In ConfigureServices add:

    services.AddMvc()
        .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
        .AddSessionStateTempDataProvider();
    
    services.AddSession();
    

    And then in Configure:

    app.UseSession();
    app.UseMvc();
    

    You'll like also want to configure session to use a persistent store like Redis or SQL Server, rather than the default of in-memory, but that's not directly relevant to the use of TempData.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器