我有以下代码:
public JsonResult AddTicketToCart(...)
{
...
Session.Add("Cart", cart);
return Json(new { IsSuccess = true }, JsonRequestBehavior.AllowGet);
}
在JS代码中:
$.get('/desk/AddTicketToCart', { clientId: clientId, sessionId: sessionId, levelId: levelId, places: places, isWithoutPlace: isWithoutPlace, delivery: delivery }, function (data) {
if (data.IsSuccess) {
if (isQuickBuy)
window.location = '/desk/paywizard';
else
window.location = $('#wiz_header .first-child>a').attr('href');
} else {
toastr.options.timeOut = 10000;
toastr.error('Error.');
}
});
此PayWizard
操作包含:
if (Session["Cart"] == null)
return new HttpNotFoundResult();
var model = CreateViewData<PersonalInfoViewData>();
return View("PersonalInformation", model);
我在Ipad上遇到404错误的问题。在桌面上一切正常。我将日志消息添加到AddTicketToCart
:
public JsonResult AddTicketToCart(...)
{
...
Session.Add("Cart", cart);
if(Session["Cart"] != null)
Logging.Log.Info("Cart not null");
else
Logging.Log.Info("Cart equal null");
var test = (CartModel) Session["Cart"];
if( test != null)
{
Logging.Log.Info("CartModel not null");
Logging.Log.Info("Tickets count: {0}", test.Tickets.Count);
}
else
Logging.Log.Info("CartModel equal null");
return Json(new { IsSuccess = true }, JsonRequestBehavior.AllowGet);
}
输出如下:
2012-11-02 09:37:34.4887 | Info | Cart not null
2012-11-02 09:37:34.4887 | Info | CartModel not null
2012-11-02 09:37:34.4887 | Info | Tickets count: 1
如您所见,会话中的Cart
存在。 Butin Paywizard
等于null。
哪里有问题?