How do I store data between requests in ASP.NET MVC?

前端 未结 2 1762
我在风中等你
我在风中等你 2021-01-11 09:42

My application reads barcodes from a USB scanner. I treat them as tokens and then build commands from those tokens. There may be a situation that I need 2 or more reads befo

相关标签:
2条回答
  • 2021-01-11 10:27

    The TempData dictionary is ideal for storing data between controller actions. It's most commonly used in the Post/Redirect/Get pattern but could apply here.

    This is a good article to read about it: http://www.devcurry.com/2012/05/what-is-aspnet-mvc-tempdata.html

    0 讨论(0)
  • 2021-01-11 10:27

    Here are a couple of possibilities that come to mind:

    On the client:

    • Cookie
    • Hidden fields

    On the server:

    • Cache (make sure to use user specific key to avoid collisions)
    • Some backend storage (such as a database)
    • ASP.NET Session
    0 讨论(0)
提交回复
热议问题