如何在“POST 后重定向"中使用 ASP.NET图案?[编辑] [英] How to use ASP.NET with "Redirect after POST" pattern? [Edited]

查看:58
本文介绍了如何在“POST 后重定向"中使用 ASP.NET图案?[编辑]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次尝试在 ASP.NET 中实现 Redirect After Post.假设我的业务对象可能需要几秒到一分钟才能完成,我使用什么顺序和语法?

I'm trying to implement Redirect After Post for the first time in ASP.NET. Assuming my business objects may take several seconds to a minute to complete, in what order, and what syntax do I use?

例如:

  1. 用户 POST

  1. User POST's

服务器发出 Server.Transfer 或 Response.Redirect

Server issues Server.Transfer or Response.Redirect

处理这种情况的最佳方法是什么?

What is the best way to handle this type of situation?

推荐答案

在这种情况下,最好坚持使用 Response.Redirect() 以便向用户的客户端发出重定向,而不是 Server.Transfer() 执行纯粹的服务器端重定向到不同的上下文.

In this case, it is probably best to just stick with Response.Redirect() so that the user's client is issued a redirect, rather than Server.Transfer() which performs a purely server-side redirect to a different context.

对于需要用户等待的进程,您可能希望使用某种异步实现,将耗时的操作放在后台线程中;同时,用户不是在空白的加载屏幕上等待,而是将 Response.Redirect() 提供给处理"页面,该页面轮询服务器以完成当前操作并更新用户.为了增加润色效果,可以考虑实施类似 Facebook 的图像上传器之类的东西,它会在用户继续正常使用网站的同时在屏幕的角落覆盖一个进度条.

Regarding the process which requires the user to wait, you may want to use some sort of asynchronous implementation where the time-consuming operation is placed in a background thread; meanwhile the user, instead of waiting on a blank loading screen, is given Response.Redirect() to a "Processing" page that polls the server for completion of the current operation and updates the user. For added polish, consider implementing something like Facebook's image uploader which overlays a progress bar in the corner of the screen while the user continues normal use of the website.

这篇关于如何在“POST 后重定向"中使用 ASP.NET图案?[编辑]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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