简体   繁体   English

会话在Windows Azure服务器上到期

[英]Session expires on windows azure server

I have stored some data in Session. 我已经在Session中存储了一些数据。 When i try to access this data on different view files (*.cshtml), it works fine on localhost. 当我尝试在其他视图文件(* .cshtml)上访问此数据时,它在localhost上运行良好。 But when I deploy it on "windowsazure.com", it results: 但是,当我将其部署在“ windowsazure.com”上时,结果是:

Object reference not set to an instance of an object. 你调用的对象是空的。 Line 14: string imageurl = Session["imageurl"].ToString(); 第14行:字符串imageurl = Session [“ imageurl”]。ToString();

Fahad 法哈德

This anwser is based on the assupmtion that you have moore than one instance of your web role running. 此答案基于您所担心的假设,而不是您运行的Web角色的一个实例。

windows Azure uses load balencing based on a round robbin princeple. Windows Azure使用基于轮询王子的负载平衡。 It also doenot support sticky sessions. 它还不支持粘性会话。 The result is that the first en second requrest to your web site are, in general, processed on 2 differnt servers. 结果是,通常在2台不同的服务器上处理网站的第一个和第二个请求。 This explains the empty state. 这说明了空状态。 You can configure your deployment to use shared memory and use the Azure cashing pattern to solve this problem. 您可以将部署配置为使用共享内存,并使用Azure兑现模式来解决此问题。

This patren is expliand in de windows Azure Training Kit. Windows Azure培训工具包中介绍了该人员。

Michiel 米歇尔

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM