请等待 ASP.NET MVC 中的页面 [英] Please wait page in ASP.NET MVC

查看:18
本文介绍了请等待 ASP.NET MVC 中的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个页面执行多个任务,需要很长时间来处理.我们希望在每项任务完成时向用户提供反馈.

A page executes a number of tasks and takes a long time to process. We want to give the user feedback as each task is completed.

在 ASP.NET 网络表单中,我们使用了 Response.Flush()

In ASP.NET webforms we used Response.Flush()

在 ASP.NET MVC 中你会用什么方法来处理这个问题?

What way would you a approach this in ASP.NET MVC?

推荐答案

您仍然可以将 Response.Write() 和 Response.Flush() 用于您想要发送的任何状态.或者,如果您在用户控件中有您的进度,您可以执行以下操作:

You can still use Response.Write() and Response.Flush() for whatever status you want to send down the wire. Or if you have your progress thingy in a user-control, you could do something like:

this.PartialView("Progress").ExecuteResult(this.ControllerContext);
this.Response.Flush();

在控制器的 action 方法中执行冗长的操作时从控制器中.

from your controller while doing your lengthy operation in the controller's action method.

您可以选择此方法或此处评论中提到的客户端方法,只是想指出服务器端仍然是可能的.

It's up to you to choose this or the client-side approach as mentioned in the comments here, just wanted to point out that server-side is still possible.

这篇关于请等待 ASP.NET MVC 中的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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