如何实现PRG在asp.net web表单正常模式 [英] How to implement PRG pattern properly in asp.net webforms

查看:179
本文介绍了如何实现PRG在asp.net web表单正常模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的三页的asp.net web表单的网站,有一个问题,后面的浏览器按钮抛出弹出...的Firefox必须发送的任何信息,将重复的任何行动。打回到了第三步时,的.aspx。

I have a simple three page asp.net webforms site and having an issue with the back browser button that throws the popup "...Firefox must send any information that will repeat any action.." when hitting back on the step3.aspx.

的流程是:在step1.aspx用户登陆,会话开始,并在产品的用户报价,被重定向到step2.aspx。在step2.aspx,您确认购买点击一个asp:按钮。 onclick事件处理程序,btnPurchase_Click,处理逻辑,购买和重定向,的Response.Redirect(step3.aspx),以step3.aspx。 Step3.aspx只显示确认页面(收据细节)。该会议被破坏的第三步,当用户点击后退按钮浏览器,它们提示重新提交后弹出。理想情况下,我希望用户打步骤1在击中背部没有重新提交提示。每个页面设置为no-cache和重定向到STEP1,如果会话是无效的。

The flow is: user lands on step1.aspx, session starts, and a user quotes on a product and gets redirected to step2.aspx. On step2.aspx, you confirm the purchase by clicking an asp:Button. The OnClick event handler, btnPurchase_Click, handles the logic for purchase and redirects, Response.Redirect("step3.aspx"), to step3.aspx. Step3.aspx simply displays the confirmation page (receipt details). The session is destroyed on step3 and when the user hits the back browser button, they are prompted with the resubmit post popup. Ideally, I want the user to hit step1 on hitting back without the resubmit prompt. Each page is set to no-cache and redirects to step1 if session is invalid.

有没有人有一个建议,一个更好的流动性?

Does anyone have a suggestion for a better flow?

本网站最终会被迁移到asp.net的MVC / AJAX,这将极有可能使得PRG的工作流程更容易实现,但就目前而言,寻找一个比较简单的方法。

This site will eventually be migrated to asp.net mvc/ajax which will most likely make the PRG workflow easier to implement but for now, looking for a relatively simple way.

推荐答案

一个简单的解决方案是绝不允许在页面上呈现回发,而是接受/存储任何信息,它被张贴,然后重定向到下一个页面(或者本身)。

A simple solution is to never allow a page to render on postback, but instead accept/store whatever information it was posted, and then redirect to the next page (or itself).

如果用户点击后退按钮这样的话,它将会回到一个GET,而不是一个POST,避免弹出。

That way if a user hits the back button, it is going back to a GET, not a POST, and avoids the popup.

这篇关于如何实现PRG在asp.net web表单正常模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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