所以我遇到了一个奇怪的问题。我在我的网站上有一些联系表格,我写入了一个html包含文件。当用户填写表单并单击提交时,我执行一些对我的ashx处理程序页面执行异步请求的jquery。现在在我的本地机器上工作,因为它应该所有的代码被命中一次,我收到1封电子邮件给自己。当我将代码放在我们的生产服务器上并填写联系表格时,我会在不同时间获得3或4份副本。奇怪的是,jquery只被命中一次所以我知道它不是多次调用ashx页面。以下是我的代码:
function procContact() {
if ($('#txtFname').val() == '' || $('#txtFname').val() == 'First Name' || $('#txtLname').val() == '' || $('#txtLname').val() == 'Last Name' || $('#txtEmail').val() == '' || $('#txtEmail').val() == 'Email' || $('#txtPhone').val() == '' || $('#txtPhone').val() == 'Phone' || isValidEmailAddress($('#txtEmail').val()) == false) {
$('#dialog').html('Please fill in all fields before submiting this request.');
$('#dialog').dialog('open');
} else {
$('#dialog').html('<div style="width: 100%; text-align:center;"><img src="images/loading.gif" /><br />One Moment While We Submit Your Request...</div>');
$('#dialog').dialog('open');
setTimeout(function () {
sendReq();
}, 1200);
}
}
function sendReq() {
$.ajax({
url: 'Myhandler.ashx?function=contact&f=' + $('#txtFname').val() + '&l=' + $('#txtLname').val() + '&e=' + $('#txtEmail').val() + '&p=' + $('#txtPhone').val(),
cache: false
}).done(function (html) {
if (html.indexOf("Success") != -1) {
//Display thank you
$('#dialog').html('Thank you for contacting the xxx and we will call you within 2 business days.');
}
});
}
现在是ASHX的东西
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
If context.Request.QueryString("function") = "contact" Then
doContact()
End If
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
Protected Sub doContact()
Dim resp As String = ""
Dim mbody As String = ""
Dim auth As New System.Net.NetworkCredential("xxxx@example.com", "ThePassword")
Dim mails As New System.Net.Mail.MailMessage()
Dim mailc As New System.Net.Mail.SmtpClient
Try
mailc.Host = "TheSmtpServer"
mailc.UseDefaultCredentials = False
mailc.Credentials = auth
'Email to xxx --------------------------------------------------------------
mbody = ""
mails = New System.Net.Mail.MailMessage("xxx@example.com", "xxx@example.com", "The Subject", mbody)
mails.IsBodyHtml = True
mailc.Send(mails)
mails.Dispose()
'End xxx Email ---------------------------------------------------------------------------------------------------------------------
'Email to Customer --------------------------------------------------------------
mbody = "the Body stuff"
mails = New System.Net.Mail.MailMessage("xxx@example.com", "xxx@example.com", "The Subject", mbody)
mails.IsBodyHtml = True
mailc.Send(mails)
mails.Dispose()
'End Customer Email ---------------------------------------------------------------------------------------------------------------------
resp = "Success"
Catch ex As Exception
resp = "Fail"
End Try
HttpContext.Current.Response.ContentType = "text/plain"
HttpContext.Current.Response.Write(resp)
End Sub
在这一点上我很困惑,为什么它只在生产时才这样做。
提前致谢
答案 0 :(得分:0)
在iOS和Android等移动平台上的Chrome浏览器(可能还有其他浏览器)会在浏览器打开并访问它们时刷新所有打开的标签页。您是否有机会在移动浏览器上打开此页面,每次页面刷新时,表单都会重新提交?
这可以解释在不同时间让电子邮件全天传播。