[英]Is it possible to get session values from action to another in MVC4?
Is there a way to get the values of the session in mvc4 application from the action. 有没有办法从动作中获取mvc4应用程序中的会话值。 For example Person to action Machine by getting the current person ID/Name ?
例如Person to action Machine通过获取当前人员ID /名称?
You can always get session values across different action methods like: 您始终可以跨不同的操作方法获取会话值,例如:
string value=Session["Name"].ToString();
Or you can use TempData to persist value across methods: 或者,您可以使用TempData在方法之间保持值:
var value= TempData["key"];
TempData.Keep();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.