我的.NET MVC3网站正在通过父网站上的iframe加载。他们通过查询字符串中的某些参数获取我网站上的控制器操作。我的动作验证这些参数,将它们存储在会话中,并执行RedirectToAction()到不同的控制器的操作。在第二个动作中,第一行代码从会话中获取这些参数。我们在DEV中没有任何问题,而且我们在QA中没有任何问题。IE中的RedirectToAction会话变量丢失
在生产中,重定向之后,会话变量被清除。这只发生在IE 8和7中。生产服务器确实有一个负载均衡器,但目前第二台服务器已关闭,问题仍然存在。这里是代码,我剥离了验证和其他一些东西。
//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 :(
}
非常感谢您提前!
更新:我实现了会话状态模式“StateServer”。没有改变。
更新:我正在看小提琴手。 IE:父站点设置会话cookie。我的网站没有。 FF:这两个网站都设置了会话cookie。
你是如何存储在生产服务器会话状态? inproc,数据库? – ryudice
我将它存储为InProc – Dimskiy