2011-09-27 152 views
1

我的.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。

+0

你是如何存储在生产服务器会话状态? inproc,数据库? – ryudice

+0

我将它存储为InProc – Dimskiy

回答

0

加载提琴手。注意Set-Cookie响应并注意cookie域。确保它匹配您的网站。然后在下一个请求(从重定向到动作)确保cookie被发送,并且再次匹配请求中的域。

+0

我用提琴手信息更新了我的问题。请告诉我是否有任何其他信息可以提供给您。 – Dimskiy

1

另一个可能的原因/解决方案是,IE浏览器不会保存cookies,如果域名有下划线(因为严格地说域名不能有下划线,所以你可能只遇到这发展),例如http://my_dev_server/DoesntWork。 Chrome或Firefox应该在这种情况下工作,并且如果您更改了您使用的域名,以避免解决下划线问题。

编号:

+0

说真的,谢谢。这解决了我的问题。几个小时的排除故障,如果没有这个答案,我甚至不会考虑这样的事情。 – Phas1c