Global.asax 与 AJAX 控制工具包中断

发布于 2024-10-14 08:20:04 字数 1746 浏览 2 评论 0原文

一切都工作正常。然后我添加了 Global.asax 并突然出现此错误:

线路:4723 错误:Sys.WebForms.PageRequestManagerParserErrorException:无法解析从服务器接收的消息。出现此错误的常见原因是通过调用 Response.Write()、响应筛选器、HttpModule 或启用服务器跟踪来修改响应。 详细信息:在 '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

Everything was working fine. Then I added the Global.asax and suddenly got this error:

Line: 4723
Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near '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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

著墨染雨君画夕 2024-10-21 08:20:04

尝试注释掉这一行,看看是否可以解决问题。

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

HTH。

Try commenting out this line and see if that fixes it.

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

HTH.

夏末的微笑 2024-10-21 08:20:04

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

使用 JavaScript 和 AJAX 工具包计时 UpdatePanel 回传

Create Timer in Global.asax for postbacks

我不想关闭这个线程,因为我认为可以提出更好的解决方案。

This is not elegant, but it works for my needs (thankfully this is an internal app). It's a two-part solution. One is for the postbacks that occur due to an UpdatePanel postback. The other is for regular postback.

Use JavaScript and AJAX Toolkit for Timing UpdatePanel Postbacks

Create Timer in Global.asax for postbacks

I'd rather not close this thread, because I think better solutions can be presented.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文