在asp.net mvc中,当某些代码运行时我将如何显示页面?
如果我想在某些脚本运行时显示加载页面,我该怎么做?
看起来,当控制器的代码执行完成时,就会呈现一个视图,但我需要向用户显示一些内容,因为代码正在执行相当多的操作。
感谢您的指点。
If I wanted to display a loading page while some script was running, how would I go about it?
It seems that a view is rendered when the controller's code has finished executing, but I need there to be something displayed to the user as the code is doing a fair amount.
Thanks for any pointers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您要么需要按照 Jason 的建议在 jQuery 调用中加载该页面,并希望它不会超时,要么将正在执行的代码移至独立组件中;通常是一个 Windows 服务,然后与其通信以开始处理并在完成后接收消息(我通常使用 MSMQ)。
You'll either need to load that page in a jQuery call, as suggested by Jason, and hope it doesn't time out, or move the code that is being executed into a standalone component; typically a Windows Service, and then communicate with it to start it processing and to receive a message when it's done (I generally use MSMQ).
您不应在 Web 请求中运行长时间任务。
相反,您必须执行以下操作:
这是一个示例(不过针对WebForms)。但不是启动新线程,而是从 ASP.NET 池中获取一个线程。
YOU SHOULD NOT RUN LONG TASKS IN WEB REQUEST.
Instead you have to do following:
Here is one example (for WebForms though). But instead of starting new thread obtain one from ASP.NET pool.