Global.asax打破了AJAX Control Toolkit

时间:2011-01-25 13:57:29

标签: asp.net asp.net-ajax ajaxcontroltoolkit global-asax

一切都很好。然后我添加了Global.asax并突然出现了这个错误:

  

线:4723   错误:Sys.WebForms.PageRequestManagerParserErrorException:无法解析从服务器收到的消息。此错误的常见原因是通过调用Response.Write(),响应过滤器,HttpModules或服务器跟踪来修改响应。   详细信息:解析'eeCtrl_Data = null; |附近时出错

<%@ Application Language="VB" %>

<script runat="server">

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    ' Code that runs on application startup
End Sub

Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
    ' Code that runs on application shutdown
End Sub

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
    ' Code that runs when an unhandled error occurs
End Sub



Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
    ' Code that runs when a new session is started
End Sub

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
    ' Code that runs when a session ends. 
    ' Note: The Session_End event is raised only when the sessionstate mode
    ' is set to InProc in the Web.config file. If session mode is set to StateServer 
    ' or SQLServer, the event is not raised.
End Sub

Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs)
    HttpContext.Current.Items("renderStartTime") = DateTime.Now
End Sub


Protected Sub Application_EndRequest(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim startTime As DateTime = CType(HttpContext.Current.Items("renderStartTime"), DateTime)
    Dim renderTime As TimeSpan = DateTime.Now - startTime
    HttpContext.Current.Response.Write("<!-- Render Time (in milliseconds): " & renderTime.TotalMilliseconds.ToString & " -->")
End Sub

2 个答案:

答案 0 :(得分:0)

尝试注释掉这一行,看看是否能修复它。

HttpContext.Current.Response.Write("<!-- Render Time (in milliseconds): " & renderTime.TotalMilliseconds.ToString & " -->")

HTH。

答案 1 :(得分:0)

这不优雅,但它可以满足我的需求(谢天谢地,这是一个内部应用程序)。这是一个由两部分组成的解决方案。一个是由于UpdatePanel回发而发生的回发。另一种是定期回发。

Use JavaScript and AJAX Toolkit for Timing UpdatePanel Postbacks

Create Timer in Global.asax for postbacks

我宁愿不关闭这个帖子,因为我认为可以提出更好的解决方案。