扩展Microsoft的ASP.NET反向AJAX“长轮询”codeplex示例

时间:2011-04-20 18:57:18

标签: asp.net wcf comet iis-7.5 reverse-ajax

我正在调查微软的reverse-AJAX sample,他们在ScriptManager中使用了很长的超时

<asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="2147483647">

用于控制等待的ManualResetEvent:

    private ManualResetEvent messageEvent = new ManualResetEvent(false);
    public Message DequeueMessage()
    {
        // Wait until a new message.
        messageEvent.WaitOne();
    }


    public void EnqueueMessage(Message message)
    {
        lock (messageQueue)
        {
            messageQueue.Enqueue(message);

            // Set a new message event.
            messageEvent.Set();
        }
    }

我注意到了

  • 将AsyncPostBackTimeout设置为较低的值(5)不会导致脚本超时或失败
  • web.config中的
  • <httpRuntime executionTimeout="5"/>似乎没有效果
  • 执行时间过长时,以下javascript似乎无法运行

       Sys.WebForms.PageRequestManager.getInstance() .add_endRequest(function (sender, args) {
       if (args.get_error() && args.get_error().name === 'Sys.WebForms.PageRequestManagerTimeoutException') {
           alert('Caught a timeout!');
           // remember to set errorHandled = true to keep from getting a popup from the AJAX library itself 
           args.set_errorHandled(true);
          }
         });
    

这让我问这些问题

  1. 影响此代码执行的正确IIS设置和.js回调是什么?

  2. 当此应用程序扩展时,IIS基础架构的哪些部分会受到压力?

  3. 如果#2成为基于WAS的WCF服务,#2中的任何内容都会发生变化吗?

1 个答案:

答案 0 :(得分:1)

AsyncPostBackTimeout的值的单位是秒,所以5表示5秒,当然我们不需要5秒等待回调。 ExecutionTimeout属性指示在ASP.NET自动关闭之前允许执行请求的最大秒数。默认值为110秒。仅当元素中的debug属性设置为false时,此超时才适用。

  

•执行时间过长时,以下javascript似乎无法运行

你怎么知道执行时间太长了?

  

1.影响此代码执行的正确IIS设置和.js回调是什么?

对于此示例,我们不需要在IIS中进行特殊设置。只有网络问题可能导致执行超时。

我很困惑为什么你要专注于超时,你使用我的样本时是否得到未处理的异常?

Werry Weng - MSFT

相关问题