什么是asp.net MVC使用TempData集合? [英] What is TempData collection used for in asp.net MVC?

查看:115
本文介绍了什么是asp.net MVC使用TempData集合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是asp.net MVC实际使用TempData集合的,我需要收集的利弊,并做我需要使用它,它认为它是建立在共享,或任何关于它的有用的信息,终于如果有人能告诉我什么时候使用它,而不是ViewData的?

What is the actual use of TempData collection in asp.net MVC, I need pros and cons of that collection, and when do I need to use it, which views it is shared upon, or any useful information about it, finally if someone can tell me when to use it rather than ViewData?

在此先感谢

CLOSED 为<一个完全相同的副本href=\"http://stackoverflow.com/questions/173159/difference-between-viewdata-and-tempdata\">http://stackoverflow.com/questions/173159/difference-between-viewdata-and-tempdata

推荐答案

TempData的用于共享控制器动作之间的数据。如果你的控制器做了RedirectToAction和目标的行动需要的数据(可能是一个特定的模型实例)时采取行动,可以存放在TempData的这个数据。使用TempData的类似于会话存储,但只为一个来回。您可以使用TempData的,当您需要将数据传递到另一个控制器行动,而不是渲染视图。

TempData is used to share data between controller actions. If your controller does a RedirectToAction and the target action needs data (perhaps a particular model instance) to act upon, you can store this data in TempData. Using TempData is similar to storing it in the session, but only for one round-trip. You use TempData when you need to pass data to another controller action rather than a view for rendering.

这篇关于什么是asp.net MVC使用TempData集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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