如何将会话数据显示到mvc4中 [英] How to display session data into mvc4

查看:64
本文介绍了如何将会话数据显示到mvc4中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有10个记录的会话

我必须根据具体情况在视图中使用和显示记录。



会话数据:

HttpContext.Current.Session [CompleteData] = objCustomer.GetAccountList();



在控制器中如何管理该会话在视图中显示

我正在尝试以下代码机器人无法在视图中显示。



I have session with 10 records
That i have to use and display records in view based on where condition.

Session Data:
HttpContext.Current.Session["CompleteData"] = objCustomer.GetAccountList();

In controller how can i manage that session to display in view
I am trying to the below code bot not able to display in view.

public ActionResult SampleBook3()
        {

            var list = Session["CompleteData"] as List<Book>;
            list = list.Where(x => x.ID == 4).ToList();
            return View(list);


        }

推荐答案

首先调试并检查列表对象是否包含数据,如果没有然后,分享你查看代码,就像你放置它一样,会非常有帮助。
first debug and check whether list object has the data and if not then , share you view code , like how you are putting it, would be really helpful.


你好b $ b

用于mvc4中的显示会话数据。

就像假设你有员工模型一样,在会话中存储会话数据并希望显示它。

所以直接你可以将会话存储在变量中,如



Hi
for display session data in mvc4.
like suppose you have employee model and in session you store the data of session and want to display it.
so directly you can store session in variable like

var EMP= (EmployeeModel)Session[Empdata];





然后显示此列表

i希望对你有所帮助

谢谢

Uttam



and then after display this list
i hope its help to you
Thanks
Uttam


这篇关于如何将会话数据显示到mvc4中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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