似乎 ASP.NET 4.0 不准备处理由 Internet Explorer 10 触发的 ImageButton 事件。问题是 IE10 将图像点击坐标作为双精度值(带小数)发送,而 ASP.NET 尝试将它们解析为整数,呈现以下类型的错误:
System.Web.HttpUnhandledException (0x80004005):
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.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.members_addtocartlogin_twostep_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\932deaba\63ff7eeb\App_Web_MyPage.aspx.28424a96.oraym_un.0.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
谷歌搜索,有人建议强制 IE10 在兼容性视图中运行。但是,添加元标记<meta http-equiv="X-UA-Compatible" content="IE=10" />
并不能解决任何问题;并且<?xml version="1.0" encoding="UTF-8">
之前添加<!DOCTYPE>
也不起作用。
有什么解决办法吗?我可以使用 Javascript 捕获点击事件并以某种方式删除小数吗?
注意:升级到 Framework 4.5 并重新编译修复了该错误。无需更改运行时版本,因为它仍然是 4.0。