Session变量是在IE丢失RedirectToAction [英] Session variable is lost on RedirectToAction in IE

查看:367
本文介绍了Session变量是在IE丢失RedirectToAction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的.NET MVC3网站正在通过父网站上的iframe中加载。他们得到在我的网站,在查询字符串中的某些参数控制器的动作。我的动作验证这些参数,将它们存储在会议并执行RedirectToAction()到不同的控制器的动作。在第二个动作,code的第一行会从会话这些参数。我们没有任何问题,在DEV,而且我们没有在QA任何问题。

My .NET MVC3 website is being loaded through an iframe on the parent website. They GET a controller's action on my website with certain parameters in the query string. My action validates these parameters, stores them in session and does RedirectToAction() to a different controller's action. In the second action, the first line of code gets these parameters from session. We did not have any problems in DEV, moreover we did not have any problems in QA.

在制作时,重定向后,会话变量被清除。这只是发生在IE 8和7的生产服务器确实有一个负载平衡器,但此刻的第二个服务器被关闭,问题依然存在。这里是code,我去掉了验证和一些其他的东西。

In Production, after the redirect, the session variable gets cleared. This only happens in IE 8 and 7. The Production server does have a load balancer, but at the moment the second server is turned off and the problem is still there. Here is the code, I stripped out validation and some other stuff.

//Here is where they come in
[HttpGet]
public ActionResult Index(string locationGUID, string OtherParam)
{
   //?locationGUID=ABCDEFGHIJKLMNOP,XXXXXXXXX&ContractInstance=2111,#####
   //some validation here

   var passedData = new PassedData
       {
         Guids = locationGUID.Split(',').ToList(),
         OtherParam = OtherParam 
       };


   PassedData = passedData;

   //more validation and init DB logging here

   return RedirectToAction("Index", "OtherController");
}

//PassedData is a property of Base Controller, from which all other controllers inherit
public PassedData PassedData
{
   get { return (PassedData)Session["PassedData"]; }
   set { Session["PassedData"] = value; }
}

//Here is Index of "OtherController", when we get here in Prod in IE, first line throws null reference exception, because PassedData is now NULL....
[HttpGet]
public ActionResult Index()
{
   ViewBag.CustInfoList = PassedData.Guids.Select(guid => GetCustomerInfo(guid).Data).ToList();
//the rest of the code is not relevant to this question, since PassedData is already NULL :(
}

非常感谢你提前!

Thank you very much in advance!

更新:我实现了会话状态模式的StateServer。什么都没有改变。

UPDATE: I implemented session state mode "StateServer". Nothing changed.

更新:我在寻找提琴手。即:父站点设置会话cookie。我的网站没有。 FF:这两个网站设置会话cookie

UPDATE: I'm looking at Fiddler. IE: The parent site sets session cookie. My site doesn't. FF: Both sites set session cookie.

推荐答案

这是因为IE不相信通过的IFrame创建的cookie

This is due to IE not trusting cookies created by IFrames

请参阅
<一href=\"http://stackoverflow.com/questions/389456/cookie-blocked-not-saved-in-iframe-in-internet-explorer\">Cookie阻塞/不是一个详细的解释和修复保存在IFRAME在Internet Explorer 。

心连心

这篇关于Session变量是在IE丢失RedirectToAction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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