消息框未显示 [英] message box not displayed

查看:57
本文介绍了消息框未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有C#web应用程序,在按钮点击事件中我们使用存储过程进行数据加载过程,运行3个小时,程序完成加载后我们使用代码显示一个消息框



 ScriptManager.RegisterStartupScript( this  this 。 GetType(),Guid.NewGuid()。ToString(),scriptString, true );并转向radiobuttion.SelectedIndex =  2 ; 





如果程序在1小时的事情很好,如果运行超过2小时,页面无响应(消息框未显示,单选按钮未更改),我尝试调试代码,代码进程通过所有行,并完成没有显示,可以任何帮助

解决方案

你的应用程序逻辑中存在一个很大的根本缺陷。 Web应用程序在处理长时间运行的进程时非常糟糕。在这种情况下,1到3小时的等待响应对于Web应用程序来说是荒谬的。当运行这样的长进程时,您应该触发一个工作线程来执行此操作,并且您对客户端的通知应该是该进程已启动。只要此工作线程正在工作,您的页面应该只识别这个并告诉用户。当流程完成时,应该有一个更直接的通知系统。可能是电子邮件或日志条目,指出该过程已完成。我个人对此的偏好如下:



1)用户启动长时间运行过程。

2)服务器收到回发并触发一个开始长时间运行过程的线程。

3)服务器响应是进程当前正在运行的通知页面。

4)用户再次点击页面。

5)服务器接收请求并检查是否已经有一个长时间运行的进程正在执行。

a)如果进程正在运行,则服务器响应是进程当前正在运行的通知。 br />
b)如果不是,则将实际页面发回。


您错过了asp.net Web开发课程中的重要课程。

 ScriptManager.RegisterStartupScript 

用于在页面上注册'javascript方法,而不是''调用/执行''方法。



在这里阅读...

http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.registerstartupscript.aspx [<一个href =http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.registerstartupscript.aspxtarget =_ blanktitle =New Window> ^ ]

http://msdn.microsoft.com/en-us/library/bb359558 .aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/ bb359558.aspx [ ^ ]



你需要一些来自你客户的轮询机制它检查长时间运行过程的状态,然后显示/隐藏消息框。


我认为这是因为请求超时。最有可能的是你的网站设置请求超时1小时。

由于超时响应将无法进入页面。 (注册脚本不会呈现)



请查看以下部分的web.config文件并相应修改



 <   system.web  >  
< httpruntime executiontimeout = 3600 >
< / httpruntime > < / system .web >





请检查以下内容还有



http://codebetter.com/petervanooijen/2006/06/15/timeout-of-an-asp-net-page/ [ ^ ]


We have C# web application ,on button click event we do a data load process using stored procedure which runs for 3 hours,after the procedure finish loading we display a message box using code

ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), scriptString, true); and turn radiobuttion.SelectedIndex = 2;



if the procedure completes in 1 hour things are fine,if it runs for more than 2 hours ,the page turns unresponsive(message box not displayed, radio button not changed),i tried debugged the code, the code process through all lines and completes with no display,can anyone help

解决方案

There is a large fundamental flaw in your application logic at play here. Web applications are really horrible at dealing with long running processes. In this case a 1 to 3 hour wait for response is ridiculous for a web app. When running a long process like this, you should be firing off a worker thread to do this and your notification to the client should be that the process has started. As long as this worker thread is working, your page should just recognize this and tell the user that. When the process completes there should be a more direct notification system in place. Perhaps an email or log entry noting that the process is complete. My personal preference on this is the following:

1) User initiates long running process.
2) Server receives the postback and fires off a thread to begin the long running process.
3) Server response is a notification page that the process is currently running.
4) User hits page again.
5) Server receives request and checks if there is already a long running process executing.
a) If the process is running then server response is the notification that the process is currently running.
b) If no, then send the actual page back.


You missed the important lesson during your asp.net web development course.

ScriptManager.RegisterStartupScript

is for ''registering'' the javascript method on the page and is NOT for ''calling/executing'' a method.

Read here...
http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.registerstartupscript.aspx[^]
http://msdn.microsoft.com/en-us/library/bb359558.aspx[^]
http://msdn.microsoft.com/en-us/library/bb359558.aspx[^]

You need some polling mechanism from your client which checks the status of your ''long running process'' and then accordingly shows/hides the message box.


I think this happen because of the request timeout. most probably your web site set request timeout for 1hr.
Because of the timeout response will not getting to the page. (registers script will not rendering)

please check the web.config file following section and modify accordingly

<system.web>
    <httpruntime executiontimeout="3600">        
</httpruntime></system.web>



And please check the following also

http://codebetter.com/petervanooijen/2006/06/15/timeout-of-an-asp-net-page/[^]


这篇关于消息框未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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