会话变量在Internet Explorer中不起作用,但在Firefox / Chrome中工作正常

时间:2011-05-16 16:24:35

标签: asp.net-mvc internet-explorer

我们使用Razor页面开发了一个带有Asp.Net MVC 3的Web应用程序。

在页面中,我们遇到问题,用户从菜单中选择项目,然后将它们添加到页面右侧的订单详细信息窗格中,其中相同类型的多个项目总计为例如3 x蒜味面包等

为此,我们添加一个T列表并将其存储在会话变量中,如下面的代码所示:

List<MunuItems> OrderItems = HttpContext.Session["_OrderItems"] as List<MunuItems>;

MunuItems newItem = new MunuItems();
// Set the newItem values

OrderItems.Add(newItem);
// Add the list to the session
HttpContext.Session.Add("_OrderItems", OrderItems);
// Retrun the partial view
return PartialView("_OrderItems", OrderItems);

这一切在Firefox或Chrome中运行良好,但是当我在Internet Explorer 8/9中尝试此操作时,行为就到处都是。每个项目中只能添加1个,尝试添加第2个项目可能会导致其他项目从列表中删除等。

您可以在此处查看此页面http://software.ayslive.com/WR_TakeAway/menu

有人可以建议如何在Internet Explorer中解决这个问题,或者为什么它在IE中不起作用?

1 个答案:

答案 0 :(得分:1)

好像你在某个地方使用ajax。

您很可能正在使用'GET'方法并且它已被缓存。如果是这样,请在ajax调用中尝试cache: false(默认为true)。