【茶包射手日記】ImageButton+UpdatePanel+IE10=ASP.NET錯誤

系統Log顯示,某個運作多年的網站最近冒出以下錯誤:

System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.Web.UI.WebControls.ImageButton.LoadPostData(String postDataKey, NameValueCollection postCollection)
   at System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection)

程式久未更動,忽然出錯令人狐疑,後來找出關鍵點,當使用IE10瀏覽時才發生問題!

爬文佐以實驗,整理出以下心得:

  1. 發生條件: 1) 使用UpdatePanel包住ImageButton的ASP.NET網頁,2) IE10使用標準模式檢視(切成相容模式可避開)
  2. 遇到相同狀況的開發者不少,該問題在MS Connect已累計超過50票
  3. 問題根源為AJAX Client Library在IE10標準模式以UpdatePanel執行ImageButton送出,X、Y座標參數出現小數點,但ASP.NET PostBack接收時只接受整數
  4. ASP.NET 3.5/4.0都有此問題,ASP.NET 4.5則已修正

理論上只需調整AJAX Client Library或ASP.NET解讀X/Y值的邏輯即可解決,而目前已有Hotfix:

  • 2783780 Hotfix rollup 2783780 is available for the .NET Framework 2.0 SP2 in Windows Server 2003 SP2 and Windows XP SP3
  • 2784147 Hotfix rollup 2784147 is available for the .NET Framework 2.0 SP2 in Windows 7 and Windows Server 2008 R2
  • 2783767 Hotfix rollup 2783767 is available for the .NET Framework 4

安裝後一帖見效,問題排除。

歡迎推文分享:
Published 27 May 2013 09:31 PM 由 Jeffrey
Filed under: ,
Views: 11,181



意見

# 阿信 said on 23 June, 2015 08:37 PM

我是用這個解決的

connect.microsoft.com/.../asp-net-4-0-and-ie10-click-on-imagebutton-in-updatepanel-produces-error-click-on-normal-button-does-not

由 Microsoft 在 2013/6/16 於 下午 09:50 公佈

Thanks for your feedback. Recently we released several GDRs for IE related bugs. You may want to have a try on these patches.

.Net 4.0

support.microsoft.com/.../2836939

.Net 2.0

support.microsoft.com/.../2836943

support.microsoft.com/.../2836942

# Jeffrey said on 24 June, 2015 04:20 AM

to 阿信,謝謝回饋。

你的看法呢?

(必要的) 
(必要的) 
(選擇性的)
(必要的) 
(提醒: 因快取機制,您的留言幾分鐘後才會顯示在網站,請耐心稍候)

5 + 3 =

搜尋

Go

<May 2013>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
 
RSS
創用 CC 授權條款
【廣告】
twMVC
最新回應

Tags 分類檢視
關於作者

一個醉心技術又酷愛分享的Coding魔人,十年的IT職場生涯,寫過系統、管過專案, 也帶過團隊,最後還是無怨無悔地選擇了技術鑽研這條路,近年來則以做一個"有為的中年人"自許。

文章典藏
其他功能

這個部落格


Syndication