简体   繁体   English

IsPostBack在ASP.NET中失败了吗?

[英]IsPostBack failing in ASP.NET?

We have an ASP.NET 3.5 application which we have created for a logistics company, which allows their customers to input deliveries/jobs and get them onto the system. 我们为物流公司创建了一个ASP.NET 3.5应用程序,它允许客户输入交付/作业并将其输入系统。

The core page in the system is the Add Job screen as as you can imagine - as the user builds up their job, we store some information of this in the Session. 系统中的核心页面是您可以想象的“添加作业”屏幕 - 当用户构建其作业时,我们会在会话中存储此信息。 Then when they commit the job, or in the Page_Load event when the request is not a postback, the session is cleared ready for the next job. 然后,当他们提交作业时,或者当请求不是回发时,在Page_Load事件中,会话被清除,准备好进行下一个作业。

We are having an issue with a small percentage of the customers, in which the users sessions appear to be being wiped before the commit happens - the users have assured us they are not trying to use multiple sessions (ie 2 windows of the same page). 我们遇到了一小部分客户的问题,其中用户会话似乎在提交发生之前被擦除 - 用户已经向我们保证他们不会尝试使用多个会话(即同一页面的2个窗口) 。 We put in some error trapping that logged whenever the sessions were cleared on that page, and it seems that 'clear session' in the Page_Load event is firing a few seconds before they click submit. 我们在该页面上清除了会话时记录了一些错误捕获,并且看起来Page_Load事件中的“清除会话”在点击提交之前几秒钟就会触发。 Please note we have a lot of autopostback controls on this page. 请注意,此页面上有很多autopostback控件。

Are there any ASP.NET quirks, or browser quirks for that matter, that will mean the IsPostback property will incorrectly be false? 是否有任何ASP.NET怪癖或浏览器怪癖,这意味着IsPostback属性将错误地错误? This is a very sporadic issue and we are having no luck in replicating this! 这是一个非常零星的问题,我们没有运气复制这个!

As adviced by many comments the session IS the wrong solution. 正如许多评论所建议的那样,会议是错误的解决方案。 It could be reset by a lot of things (app pool recycling for example). 它可以通过很多东西重置(例如应用程序池回收)。

You should not force the user not to use different browsers or tabs, so the right choice is move data to ViewState/Control state. 您不应强迫用户不要使用不同的浏览器或选项卡,因此正确的选择是将数据移动到ViewState / Control状态。

If for some weird reason you still have to keep data in the session consider switching to a persistant session storage (ie using sql Server). 如果出于某种奇怪的原因,您仍然需要在会话中保留数据,请考虑切换到持久会话存储(即使用sql Server)。

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

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