如何在ASP.NET MVC中的请求之间存储数据? [英] How do I store data between requests in ASP.NET MVC?

查看:38
本文介绍了如何在ASP.NET MVC中的请求之间存储数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序从USB扫描仪读取条形码.我将它们视为令牌,然后从这些令牌构建命令.在可能的情况下,我需要两次或更多次读取才能创建命令.我需要以某种方式存储以前的读物.如何在两次请求之间保留一些数据?我不要在我的视图中使用这些令牌.

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 before I can create a command. I need to store previous reads in some way. How can I keep some data between request? I do not to use that tokens in my view.

仅命令的结果可能会显示在视图中.

Only results of commands may be displayed in the view.

推荐答案

TempData 字典是在控制器动作之间存储数据的理想选择.它在发布/重定向/获取"模式中最常用,但可以在此处应用.

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.

这是一篇不错的文章,可供阅读:http://www.devcurry.com/2012/05/what-is-aspnet-mvc-tempdata.html

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

这篇关于如何在ASP.NET MVC中的请求之间存储数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆