UpdatePanel 與 Sys.WebForms.PageRequestManagerParserErrorException

朋友問:「為什麼程式加了 ScriptManager 和 UpdatePanel 之後,原本沒問題的程式,卻出現 Sys.WebForms.PageRequestManagerParserErrorException?」

Eilon Lipton 有篇文章提供了很詳細的說明,包括該錯誤的意義、發生原因、以及解決方法:Sys.WebForms.PageRequestManagerParserErrorException - what it is and how to avoid it

常見的原因包括:
  • 在程式中呼叫 Response.Write 輸出資料至用戶端頁面。這會導致 UpdatePanel 無法對這些資料編碼。
  • 網站有使用 response filter。
  • 網站有使用 HTTP modules。
  • 開啟網頁的 trace 功能。
  • 在程式中呼叫 Server.Transfer。
那位朋友碰到的情況,是程式中使用 Server.Transfer 的方式轉址。改成 Response.Redirect 就解決了。

沒有留言:

技術提供:Blogger.
回頂端⬆️