Session Variable not working in Internet Explorer,

2019-08-04 03:19发布

问题:

We've developed a web app with Asp.Net MVC 3 using Razor pages.

In the page we're having problems with a user selects items from a menu and they're added to the order details pane on the right of the page, where multiple items of the same type are totaled up e.g. 3 x Garlic Bread etc.

To do this we add to a list of T and store it in a session variable as in the following code:

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);

This all works fine in Firefox or Chrome, but when I try this in Internet Explorer 8 / 9 the behavior is all over the place. Only 1 of each item can be added, trying to add 2nd items can cause other items to drop off the list etc.

You can view the page here http://software.ayslive.com/WR_TakeAway/menu

Can anyone suggest how this can be fixed in Internet Explorer or why it's not working in IE?

回答1:

It appears as though you are using ajax somewhere.

It is quite possible that you are using the 'GET' method and that it is cached. If so try cache: false in your ajax call (the default is true).