简体   繁体   English

doPostBack AJAX ASP.NET WebForms中引发了可疑错误

[英]Suspected error thrown in doPostBack AJAX ASP.NET WebForms

We have a client who completes simple forms online, generally using Windows as an OS; 我们有一个客户在线完成简单表格,通常使用Windows作为操作系统; various browsers are used. 使用各种浏览器。 This works fine most of the time, however, very occasionally the submission process fails. 这在大多数情况下都可以正常工作,但是,提交过程偶尔会失败。 The code for submission is below: 提交的代码如下:

<a onclick="return beginLoad(true,1,'Your Data is being submitted, Please Wait',false,'');" id="btnSubmitRPT" class="Tool-Lbl-Footer" href="javascript:__doPostBack('btnSubmitRPT','')">SUBMIT</a>

The begin load method shows the traditional spinning circle as a request to the server is made; 开始加载方法显示传统的旋转圆圈作为对服务器的请求; this always returns true. 这总是返回true。 However, when this issue occurs, whilst monitoring the network traffic in Chrome using the developer tools, no request is made to the server; 但是,当出现此问题时,使用开发人员工具监控Chrome中的网络流量时,不会向服务器发出请求; normally we'd see an XHR, but there is no request. 通常我们会看到XHR,但没有请求。 On the server side, we can also see this as the logs are empty during the submission period, ie the server wasn't contacted. 在服务器端,我们也可以看到这一点,因为在提交期间日志是空的,即未联系服务器。 This has led us to believe there is a problem within the framework itself that is causing some sort of error and aborting the submission process, but we've no idea what this could be 这使我们相信框架内部存在导致某种错误并中止提交过程的问题,但我们不知道这可能是什么

We know the code gets to the line below theForm.__EVENTTARGET.value = eventTarget; 我们知道代码到了theForm下面的行.__ EVENTTARGET.value = eventTarget; because the form's __EVENTTARGET hidden input field is set with the value 'btnSubmitRPT', however, it appears that the theForm.submit() doesn't execute, or aborts for some reason, code below: 因为表单的__EVENTTARGET隐藏输入字段设置为值'btnSubmitRPT',但是,似乎theForm.submit()由于某种原因没有执行或中止,代码如下:

var theForm = document.forms['webform'];
if (!theForm) {
    theForm = document.webform;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}

Does anyone know why this would fail intermittently, even when the user puts the same data in the form, sometimes it works occasionally is doesn't. 有没有人知道为什么这会间歇性地失败,即使用户在表单中放入相同的数据,有时偶尔工作也不会。 There seems to be no pattern to this behaviour. 似乎没有这种行为的模式。 The even stranger thing is if you click the submission button again it will submit the request so work. 更奇怪的是,如果再次单击提交按钮,它将提交请求以便工作。

This happens in all browsers. 这种情况发生在所有浏览器 The weird thing is that we've never experienced this with any of our other clients who use our software. 奇怪的是,我们从未经历过使用我们软件的任何其他客户的这种情况。

If anyone can help give us some pointers on where to look to resolve this or some sort of magical solution that would be great. 如果有人可以帮助我们提供一些指示,可以解决这个问题,或者某种神奇的解决方案。

All the best, 祝一切顺利,

Stuart. 斯图尔特。

Ok, so I got over this problem. 好的,所以我克服了这个问题。 Upgraded the .NET Framework in the project and all dependencies to 4.7.2, and the problem went away. 将项目中的.NET Framework和所有依赖项升级到4.7.2,问题就消失了。 Happy customer = perplexed and confused developer. 快乐的客户=困惑和困惑的开发人员。

Thanks those that looked. 谢谢那些看起来。

Stu. 斯图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM