在长时间运行操作完成之前,保持ASP.NET页面的最佳方法是什么?

时间:2021-05-06 20:57:47

Javascript?

Metatag refresh?

Response.Redirect (to self)

Response.Redirect(对自己)

Server.Transfer (to self)

Server.Transfer(自我)

Ajax update panel?

Ajax更新面板?

6 个解决方案

#1


Let's look at the options:

我们来看看选项:

Javascript?

That works fine, as long as the user haven't disabled it.

只要用户没有禁用它,它就可以正常工作。

Metatag refresh?

A deprecated method in favour of the Javascript method. However, you could use it as a backup if the user has disabled Javascript.

一种不赞成使用Javascript方法的方法。但是,如果用户已禁用Javascript,您可以将其用作备份。

Response.Redirect (to self)

Response.Redirect(对自己)

That doesn't work, as the browser would not show anyhing useful for the user while redirecting. Also, the browser will stop requesting after a certain number of redirects to protect the user from infinite redirects.

这不起作用,因为浏览器在重定向时不会显示对用户有用的任何内容。此外,浏览器将在一定数量的重定向后停止请求,以保护用户免受无限重定向。

Server.Transfer (to self)

Server.Transfer(自我)

Doesn't work either, as the code on the server would just loop without sending anything to the browser. The effect is the same as just having a loop in your code.

也不起作用,因为服务器上的代码只是循环而不向浏览器发送任何内容。效果与在代码中只有一个循环相同。

Ajax update panel?

Ajax更新面板?

Works fine, as long as the user haven't disabled Javascript. It's basically the same as the first option, only the Javascript does the request itself instead of letting the browser do the request.

工作正常,只要用户没有禁用Javascript。它与第一个选项基本相同,只有Javascript执行请求本身而不是让浏览器执行请求。

#2


If you can report any kind of progress to the user, I tend to run with an asxh and a variation of a forever frame. Add a bit of jQuery UI Dialog and jQuery UI Progress Bar and you've got a shiny way of holding the users attention while you do the heavy lifting on the server.

如果您可以向用户报告任何类型的进度,我倾向于使用asxh和永久帧的变体运行。添加一些jQuery UI Dialog和jQuery UI Progress Bar,当你在服务器上进行繁重的工作时,你会有一种闪亮的方式来吸引用户的注意力。

I gave some example code at 874204 that demonstrates the technique.

我在874204给出了一些示例代码,演示了该技术。

If you can't give progress to the user, I tend to still use UI dialog and pop a "please wait, processing..." message with a web two dot oh compliant spinny gif.

如果你无法向用户提供进展,我倾向于仍然使用UI对话框并弹出一个“请等待,处理...”消息与web两点哦兼容spinny gif。

#3


Check out this article on Asynchronous Pages. Here's also an example from CodeProject that includes Asynchronous pages and META-REFRESH.

查看有关异步页面的这篇文章。这里也是CodeProject的一个例子,它包括异步页面和META-REFRESH。

#4


You can find a sample implementation of this kind of functionality in the Beer House Starter Kit- http://www.asp.net/Downloads/starter-kits/the-beer-house/.

您可以在Beer House Starter Kit中找到此类功能的示例实现 - http://www.asp.net/Downloads/starter-kits/the-beer-house/。

The pages SendingNewsLetter.aspx and SendNewsLetter.aspx will be useful to you. This might be overkill for your need though- it even shows progress of the long running operation.

SendingNewsLetter.aspx和SendNewsLetter.aspx页面对您有用。虽然这可能对你的需求有些过分 - 甚至可以显示长时间运行的进度。

#5


What about using the AJAX WebModalAnchor to pop up a window with a cancel button?

如何使用AJAX WebModalAnchor弹出带有取消按钮的窗口?

Hope this helps,

希望这可以帮助,

Bill

#6


I'd recommend using Ajax and displaying an UpdateProgress so the user knows it's still churning away.

我建议使用Ajax并显示一个UpdateProgress,以便用户知道它仍然在搅拌。

#1


Let's look at the options:

我们来看看选项:

Javascript?

That works fine, as long as the user haven't disabled it.

只要用户没有禁用它,它就可以正常工作。

Metatag refresh?

A deprecated method in favour of the Javascript method. However, you could use it as a backup if the user has disabled Javascript.

一种不赞成使用Javascript方法的方法。但是,如果用户已禁用Javascript,您可以将其用作备份。

Response.Redirect (to self)

Response.Redirect(对自己)

That doesn't work, as the browser would not show anyhing useful for the user while redirecting. Also, the browser will stop requesting after a certain number of redirects to protect the user from infinite redirects.

这不起作用,因为浏览器在重定向时不会显示对用户有用的任何内容。此外,浏览器将在一定数量的重定向后停止请求,以保护用户免受无限重定向。

Server.Transfer (to self)

Server.Transfer(自我)

Doesn't work either, as the code on the server would just loop without sending anything to the browser. The effect is the same as just having a loop in your code.

也不起作用,因为服务器上的代码只是循环而不向浏览器发送任何内容。效果与在代码中只有一个循环相同。

Ajax update panel?

Ajax更新面板?

Works fine, as long as the user haven't disabled Javascript. It's basically the same as the first option, only the Javascript does the request itself instead of letting the browser do the request.

工作正常,只要用户没有禁用Javascript。它与第一个选项基本相同,只有Javascript执行请求本身而不是让浏览器执行请求。

#2


If you can report any kind of progress to the user, I tend to run with an asxh and a variation of a forever frame. Add a bit of jQuery UI Dialog and jQuery UI Progress Bar and you've got a shiny way of holding the users attention while you do the heavy lifting on the server.

如果您可以向用户报告任何类型的进度,我倾向于使用asxh和永久帧的变体运行。添加一些jQuery UI Dialog和jQuery UI Progress Bar,当你在服务器上进行繁重的工作时,你会有一种闪亮的方式来吸引用户的注意力。

I gave some example code at 874204 that demonstrates the technique.

我在874204给出了一些示例代码,演示了该技术。

If you can't give progress to the user, I tend to still use UI dialog and pop a "please wait, processing..." message with a web two dot oh compliant spinny gif.

如果你无法向用户提供进展,我倾向于仍然使用UI对话框并弹出一个“请等待,处理...”消息与web两点哦兼容spinny gif。

#3


Check out this article on Asynchronous Pages. Here's also an example from CodeProject that includes Asynchronous pages and META-REFRESH.

查看有关异步页面的这篇文章。这里也是CodeProject的一个例子,它包括异步页面和META-REFRESH。

#4


You can find a sample implementation of this kind of functionality in the Beer House Starter Kit- http://www.asp.net/Downloads/starter-kits/the-beer-house/.

您可以在Beer House Starter Kit中找到此类功能的示例实现 - http://www.asp.net/Downloads/starter-kits/the-beer-house/。

The pages SendingNewsLetter.aspx and SendNewsLetter.aspx will be useful to you. This might be overkill for your need though- it even shows progress of the long running operation.

SendingNewsLetter.aspx和SendNewsLetter.aspx页面对您有用。虽然这可能对你的需求有些过分 - 甚至可以显示长时间运行的进度。

#5


What about using the AJAX WebModalAnchor to pop up a window with a cancel button?

如何使用AJAX WebModalAnchor弹出带有取消按钮的窗口?

Hope this helps,

希望这可以帮助,

Bill

#6


I'd recommend using Ajax and displaying an UpdateProgress so the user knows it's still churning away.

我建议使用Ajax并显示一个UpdateProgress,以便用户知道它仍然在搅拌。