We have a convoluted ASP.Net 2.0 situation I need to resolve. I haven't written code since around 2010, but I'm probably the only one at my company who has a shot at getting this working.
We have a legacy Windows 2003 webserver that we're going to replace. But our company website, two ClickOnce deployments and several internal utilities are running on it, and service cannot be interrupted. This website was written in ASP.Net 2.0 (vb.net codebehind). So we need to be able to migrate the site to a replacement server.
We set up a Windows 2012 server that we plan to use to host the old website until we develop a new one, at which time we'll continue the upgrade to the latest Windows Server platform.
In the midst of this process, major browsers began refusing less than TLS 1.2 protocol, which cannot be supported on Windows Server 2003. The problem showed itself when clients tried to submit a fillable contact form we have running. Form submission was refused due to the TLS issue.
So, we used our wildcard SSL certificate and bound it to the new 2012 server. A subdomain was created, called contact.ourdomain.com. We have a copy of our website running on the new server. All links to the contact form were updated to point to 'contact.ourdomain.com/contact.aspx', which is being hosted on the new server. So now the TLS issue is being avoided.
However, there is a problem with the form. When executed in Visual Studio, it works correctly. But once it is published to the new server, the form is not showing the confirmation dialog or redirecting to our home page. This means that once the form is filled out and you click Submit, it sends the email message and then just sits there. It doesn't show the dialog or redirect. So not only do clients end up submitting the form like 5 times, they don't even know if it worked. How do I force this code to run to completion?
Any possible way to resolve this issue is fine. Javascript, whatever. This is a temporary fix and I just need it to work till the end of the year; the move to the new server will be finished by then.
'''Imports System.Net.Mail
Partial Public Class Contact Inherits 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
End Class'''
Aucun commentaire:
Enregistrer un commentaire