asp.net - ASP.Net 2.0:提交后表单不重定向
问题描述
我们有一个复杂的 ASP.Net 2.0 情况需要解决。自 2010 年左右以来,我就没有编写过代码,但我可能是我公司中唯一一个有机会完成这项工作的人。
我们有一个将要替换的旧版 Windows 2003 网络服务器。但是我们公司的网站、两个 ClickOnce 部署和几个内部实用程序都在上面运行,并且服务不能中断。这个网站是用 ASP.Net 2.0 (vb.net codebehind) 编写的。因此,我们需要能够将站点迁移到替换服务器。
我们设置了一个 Windows 2012 服务器,我们计划使用它来托管旧网站,直到我们开发一个新网站,届时我们将继续升级到最新的 Windows Server 平台。
在此过程中,主要浏览器开始拒绝低于 TLS 1.2 的协议,Windows Server 2003 无法支持该协议。当客户端尝试提交我们正在运行的可填写联系表单时,问题就出现了。由于 TLS 问题,表单提交被拒绝。
因此,我们使用了通配符 SSL 证书并将其绑定到新的 2012 服务器。创建了一个名为contact.ourdomain.com 的子域。我们在新服务器上运行了我们网站的副本。联系表格的所有链接都更新为指向“contact.ourdomain.com/contact.aspx”,该链接托管在新服务器上。所以现在正在避免 TLS 问题。
但是,表格存在问题。在 Visual Studio 中执行时,它可以正常工作。但是一旦它被发布到新服务器,表单就不会显示确认对话框或重定向到我们的主页。这意味着一旦填写表格并单击提交,它就会发送电子邮件,然后就坐在那里。它不显示对话框或重定向。因此,客户不仅最终提交了 5 次表单,他们甚至不知道它是否有效。如何强制此代码运行完成?
解决此问题的任何可能方法都可以。Javascript,随便。这是一个临时修复,我只需要它工作到年底;届时将完成向新服务器的迁移。
'''导入 System.Net.Mail
部分公共类联系人继承 System.Web.UI.Page Public StrPubMessage As String Public BlnReady As Boolean
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
lblMsgBox.Visible = False
Else
End If
End Sub
Public Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click
Try
' validate the Captcha to check we're not dealing with a bot
Dim isHuman As Boolean = frmCaptcha.Validate(txtCaptchaCode.Text)
txtCaptchaCode.Text = Nothing
If Not isHuman Then
MsgBox("Please enter Captcha code.", MsgBoxStyle.OkOnly, "LDC Website")
Else
Dim emailclient As New SmtpClient("smtp.office365.com")
emailclient.EnableSsl = True
emailclient.Credentials = New System.Net.NetworkCredential("notifications@Ourdomain.com", "Our_Domain2020")
Dim toEmailAddress As New MailAddress("email@Ourdomain.com")
Dim fromEmailAddress As New MailAddress("notifications@Ourdomain.com")
Dim emailMessage As New MailMessage(fromEmailAddress, toEmailAddress)
Dim messageString As String
emailMessage.IsBodyHtml = False
emailMessage.BodyEncoding = System.Text.Encoding.UTF32
emailMessage.Subject = "Message from website"
messageString = "The following is an email inquiry from Ourdomain.com:" & vbCrLf + Chr(13) + Chr(10)
messageString = messageString + "Name: = " + txtName.Text & vbCrLf
messageString = messageString + "Company Name: = " & txtCoName.Text & vbCrLf
messageString = messageString + "EMAIL: = " & txtEmail.Text & vbCrLf
messageString = messageString + "General Comment" & vbCrLf & vbCrLf & txtComment.Text & vbCrLf
messageString = messageString + "End of inquiry." & vbCrLf & vbCrLf
emailMessage.Body = messageString
emailclient.Send(emailMessage)
MsgBox("Your message was successfully transmitted to our team." _
& vbCrLf & "You will be contacted within 1 business day." _
& vbCrLf & "Thank you for your inquiry.", MsgBoxStyle.OkOnly, "Our Website")
Response.Redirect("https://www.Ourdomain.com", False)
End If
Catch ex As Exception
MsgBox("Your message could not be sent due to an unknown error. Please try again.", MsgBoxStyle.OkOnly)
Response.Redirect("https://www.Ourdomain.com", False)
End Try
End Sub
结束课程'''
解决方案
推荐阅读
- python - 使用 python reduce() 有点像 javaScripts reduce() 但这样做失败
- php - PHP:如何优化循环通过 CSV 并根据列中的值将行写入文件
- c# - INSERT 语句与 FOREIGN KEY 约束冲突 语句已终止
- java - 如果输入了错误的类型作为参数,我如何让我的方法返回特定值?
- json - 将Json字符串反序列化为对象java
- java - 为什么我不能继承 add2 类中数字 3 的值?
- javascript - Google Maps Javascript 两个 InfoWindow 用于相同的标记
- python - Python:请求 URL 并将 JSON 数据返回到脚本
- wear-os - 活动停止后保持服务活动
- bash - 我有一个需要在目录中搜索的键列表,然后打印未找到的键